Domanda

I have been doing rendering of directory structure in my jsf1.1 web page using Apache myfaces tomahawk tree2 component. In backing bean i have written a recursive function call to initialize folder names and documents names to be displayed in tree2 component.

Instance variables are:

private TreeNode treeData;
TreeNodeBase personNode=new TreeNodeBase();
TreeNodeBase folderNode;

In Method1:

personNode = new TreeNodeBase("folder",value from the database, false);
personNode.getChildren().add(new TreeNodeBase("document", document name, true));

If created folder has sub folders i call another method to find it's sub folders as well as it's documents. If exists adding the folders to parent folder with below code.

In Method2:

while(end of all folders list) {
folderNode = new TreeNodeBase("person", folder1, false);// add all folders
folderNode.getChildren().add(new TreeNodeBase("document", document name, true));//add document
personNode.getChildren().add(folderNode); //add sub folders to parent folder
}

Method which is binded to component returns:

treeData.getChildren().add(personNode);
return treeData;

With this code i end up in adding all sub folders to single folder. So, i need to get parent folder reference(or ID) in order to add their child folders to it.

My question is: How to get the created folder id(or reference) with this line code or else suggest any other way of finding solution:

personNode = new TreeNodeBase("folder",value from the database, false);

Thank you:)

È stato utile?

Soluzione

To identify each new treenodebase() to reference(or use) later we could use method setIdentifier() of TreeNodeBase class. By that we can identify each node uniquely.

folderNode.setIdentifier(folder identification number);// where folderNode is TreeNodeBase Object and folder identification number can be any unique number for created node.
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top