简体   繁体   English

如何在Apache myfaces战斧tree2组件中获取父节点的引用

[英]How to get reference of parent Node in Apache myfaces tomahawk tree2 component

I have been doing rendering of directory structure in my jsf1.1 web page using Apache myfaces tomahawk tree2 component. 我一直在使用Apache myfaces tomahawk tree2组件在jsf1.1网页中呈现目录结构。 In backing bean i have written a recursive function call to initialize folder names and documents names to be displayed in tree2 component. 在后备bean中,我编写了一个递归函数调用,以初始化要在tree2组件中显示的文件夹名称和文档名称。

Instance variables are: 实例变量是:

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

In Method1: 在方法1中:

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: 在方法2中:

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. 因此,我需要获取父文件夹引用(或ID)才能向其添加子文件夹。

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: 我的问题是:如何使用此行代码获取创建的文件夹ID(或引用),或者提出寻找解决方案的任何其他方法:

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

Thank you:) 谢谢:)

To identify each new treenodebase() to reference(or use) later we could use method setIdentifier() of TreeNodeBase class. 为了稍后标识每个新的treenodebase()以供参考(或使用),我们可以使用TreeNodeBase类的setIdentifier()方法。 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.

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM