我正在Web应用程序中使用Wicket的Tree组件.但是空文件夹以文件方式显示.
像这样:
贝娄是我使用DefaultTreeModel和Tree的地方:
PDMinterface pdmI = new PDMinterface();
DefaultMutabletreeNode rootTreeNode = pdmI.getDocTree(); //文档树根结点,由PDM接口提供
DefaultTreeModel treeModel = new DefaultTreeModel(rootTreeNode);
treeModel.setAsksAllowsChildren(true);
并且我确定folder5设置为允许孩子:
public DefaultMutableTreeNode getDocTree(){
DefaultMutableTreeNode root = new DefaultMutableTreeNode();
root.setAllowsChildren(true);
FolderNode rootFolder = new FolderNode(0, "root", "Jiajun", true);
root.setUserObject(rootFolder);
for(int i=0; i < 5; i++){
DefaultMutableTreeNode newnode = new DefaultMutableTreeNode();
newnode.setAllowsChildren(true);
FolderNode newFolder = new FolderNode(i+1, "Folder" + Integer.toString(i+1), "Jiajun", false);
newnode.setUserObject(newFolder);
root.add(newnode);
if(i < 4){
for(int j=0; j < 5; j++){
DefaultMutableTreeNode newdocNode = new DefaultMutableTreeNode();
newdocNode.setAllowsChildren(false);
DocNode newDoc = new DocNode(10*(i+1) + j, "Document" + Integer.toString(10*(i+1)+j), "Jiajun");
newdocNode.setUserObject(newDoc);
newnode.add(newdocNode);
}
}
}
任何人都可以帮忙吗?