You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by mmca <m....@asidua.com> on 2006/04/05 13:08:30 UTC

Quick solution to tree2's preserveToggle

I use the tomahawk tree2 to display contents in my database.  The tree
structure is created in my code and leaf and node elements will vary greatly
depending what the user is viewing.

I overcame the problem of the preserve toggle attempting to output a node
when it was actually a leaf, by setting preserveToggle="false" though now I
want some way to retain the toggle state.  Is there any way to retain toggle
state depending on root id, or a way to attempt to redraw the tree, and if a
leaf is found where a node is expected, to render the leaf and ignore the
problem?

Code to create tree

// root node
TreeNode treeData = new TreeNodeBase("a", value.getTitle(), value.getId(),
false);
// it's children
for(iterator iter=values.iterator;iter.hasNext() ) {
  // go through list making tree node's again
  TreeNode node = new TreeNode(...)
  // go through it's children if it has any
  for(iterator iter2=values2.iterator;iter2.hasNext() ) {
    TreeNode node2 = new TreeNode(...)
    node.getChildren().add(node2)
  }
  treeData.getChildren().add(node)
}


Any sort of solution to smartly preserve the toggle state and control when
to delete this in the controller, or a solution as mentioned above would be
very much appreciated.
Cheers
Michael.
--
View this message in context: http://www.nabble.com/Quick-solution-to-tree2%27s-preserveToggle-t1398764.html#a3762228
Sent from the MyFaces - Users forum at Nabble.com.


Re: Quick solution to tree2's preserveToggle

Posted by mmca <m....@asidua.com>.
I've been reading through alot of topics regarding tree 2 and I think I know
what I'm trying to do more clearly, so I'll try to give a better explanation
of it in the hope someone has come across it before.

Basically the structure of the tree that I am rendering regarding what is
leaf and node can change often.  What I want to do is preserveToggle of the
tree, but only apply it if this will not throw errors.  If applying it will
result in errors (ie trying to render a expanded leaf node) I will set the
preserveToggle to false so the tree is totally unexpanded.  How can I grab
hold of the toggled state in my backing bean?

Any help much appreciated.
--
View this message in context: http://www.nabble.com/Quick-solution-to-tree2%27s-preserveToggle-t1398764.html#a3781471
Sent from the MyFaces - Users forum at Nabble.com.