This content has been marked as final.
Show 5 replies
-
1. Re: The role of child identifier in TreeNode
ilya_shaikovsky Nov 25, 2008 5:30 AM (in response to koloale1)you could iterate through the childs using getChildren() in your listener and remove the node you need.
-
2. Re: The role of child identifier in TreeNode
koloale1 Nov 25, 2008 7:00 AM (in response to koloale1)Thank you for your answer, it can help. But how about removing by identifier. When adding children I have to provide a not arbitrary id (e.g. it should be unique on a particular level), but is there any way to reuse that id?
"ilya_shaikovsky" wrote:
you could iterate through the childs using getChildren() in your listener and remove the node you need. -
3. Re: The role of child identifier in TreeNode
ilya_shaikovsky Nov 25, 2008 7:49 AM (in response to koloale1)please paste your current code.. I'll paste some additions according to the code if need.
-
4. Re: The role of child identifier in TreeNode
koloale1 Nov 25, 2008 8:29 AM (in response to koloale1)void createTree() { root = new TreeNodeImpl<String>(); int ind = 0; for (Object child : children) { TreeNodeImpl<String> node = new TreeNodeImpl<String>(); node.setData(child); root.addChild(ind++, node); } public void processSelection(NodeSelectedEvent event) { UITree tree = (UITree) event.getComponent(); curObject = tree.getTreeNode().getData(); // how here I can get identifier that I passed into addChild method during tree creation } public void doDelete() { // where does identifier go from curNode.getParent().removeChild(identifier); }
I already understood that method doDelete() can be implemented by iterating through all children and finding current object to delete, but I'd like to use more convenient method removeChild(). If there is no way to get identifier of the current node then who calls removeChild method at all? -
5. Re: The role of child identifier in TreeNode
nbelaevski Nov 25, 2008 9:16 AM (in response to koloale1)Hi,
Child identifier is used to create so called row keys for each model node. Tree component uses them to process submitted data and render tree structure.
Just extend TreeNodeImpl the way you like.