我将我的应用程序从ZK 5.011升级到6.5,现在没有调用TreeitemRenderer的render()。
这是我的代码:
// --- node (domain) class ---
public class CatalogTreeNode implements Serializable {
private static final long serialVersionUID = 1L;
public CatalogTreeNode( int nodeID, String nodeName, CatalogTreeNode parent ) {
this.nodeID = nodeID;
this.nodeName = nodeName;
}
private int nodeID;
private String nodeName;
// setters and getters
}
// --- tree model class ---
// I need "load on demand"
public class CatalogTreeModel extends AbstractTreeModel<CatalogTreeNode>
{
private static final long serialVersionUID = 2L;
public CatalogTreeModel( CatalogTreeNode root )
{
super( root );
//...
}
@Override
public CatalogTreeNode getChild( CatalogTreeNode parent, int childIndex ) {
//...
}
@Override
public int getChildCount( CatalogTreeNode node ) {
//...
}
@Override
public boolean isLeaf( CatalogTreeNode node ) {
//...
}
@Override
public int getIndexOfChild( CatalogTreeNode parent, CatalogTreeNode child ) {
//...
}
}
// -- using in controller ---
public class MainFormController extends GenericForwardComposer<Component> {
private Tree myTree;
// ...
@Override
public void doAfterCompose( Component comp ) throws java.lang.Exception {
super.doAfterCompose(comp);
CatalogTreeNode catTreeRoot = new CatalogTreeNode( -1, "ROOT", null );
catTreeRoot.addChild( new CatalogTreeNode( 1, "One", catTreeRoot ) );
catTreeRoot.addChild( new CatalogTreeNode( 2, "Two", catTreeRoot ) );
CatalogTreeModel model = new CatalogTreeModel( catTreeRoot );
// model != null - Ok!
CatalogTreeItemsRenderer renderer = new CatalogTreeItemsRenderer();
// render != null - Ok!
myTree.setItemRenderer( renderer );
myTree.setModel( model );
// ...
}
// renderer
private class CatalogTreeItemsRenderer implements TreeitemRenderer<CatalogTreeNode> {
@Override
public void render( Treeitem item, CatalogTreeNode data, int index ) throws Exception {
...
}
}
}
使用ZK v.5.011这个工作正常,但是在升级ZK到v.6.5之后,根本没有调用CatalogTreeItemsRenderer的渲染(...)并且树是空的!