You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by "Patel, Hitesh (Exchange)" <hp...@Bear.com> on 2005/08/26 20:29:03 UTC

Tree2 - problem with the states of the nodes

I am using the tree2 in Myfaces and my requirement is to get the data
from the database and build the tree nodes every time a node is
expanded. If an expanded node is collapsed I want to remove the nodes
under this node from the tree and add the nodes afresh by getting the
data from the database when that node is expanded again.

 

I am facing the problem that even if I remove the child nodes of the
node that I collapse, when I add the nodes again when I expand that node
it seems to remember the state of the child nodes before I collapsed the
parent node and removed these child nodes. So if I had a child node
which was expanded before I removed it, the next time I expand the
parent node and add these child nodes and I click on this child node
that was expanded it will not expand on the first click as it was
expanded when I removed this node. On the second click It expands. I
believe it is collapsing the state on the first click and on the second
click it is then expanding. How do I remove the state of the child nodes
that I remove from the tree.

 

I use.....

 

List children = node.getChildren();

Children.removeAll(children);

 

.... to remove the nodes. Is there another better way to remove the
nodes or am I doing it correctly. IF this is correct then how do I
remove the states of the nodes the tree maintains.

 

Any help is much appreciated.