package zk.support.treeerror; import org.zkoss.zul.AbstractTreeModel; public class HierarchyTreeModel extends AbstractTreeModel> { private static final long serialVersionUID = 1L; public HierarchyTreeModel(String data) { super(new Hierarchy(data, false)); } @Override public boolean isLeaf(Hierarchy node) { return node.isLeaf(); } @Override public Hierarchy getChild(Hierarchy parent, int index) { if(parent.getChildren() == null) { System.out.println("loading children of: " + parent.getData()); //alternatively load from DB here for(int i = 0; i < getChildCount(parent); i++) { String childData = parent.getData() + "-" + (i + 1); parent.addChildData(childData, parent.getLevel() >= 2); } } return parent.getChildren().get(index); } @Override public int getChildCount(Hierarchy parent) { //alternatively load from DB here return parent.isLeaf() ? 0 : 400; } }