myfaces-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Hendrik Beck \(camunda\)" <>
Subject Tomahawk Tree2 / Expanding nodes programmatically via events
Date Wed, 01 Mar 2006 11:13:01 GMT
Hi all!

In our current project we are using the Tomahawkt tree2 component. Due to
some special requirements I have to control the state of expanded nodes
programmatically. Therefore I have implemented a map which contains the
nodeIds ("0", "1:2:0" and so on) of the tree nodes and my own Ids. So I can
expand one single node by calling my own method "expandNode( String myNodeId
)" which translates my own IDs into tree IDs and then talks to the tree
component directly.

This method then fires a ToggleExpandEvent on the tree just as the
HtmlTreeRenderer class does in its "decode()" method (This mechanism is
executed when the "+" and "-" symbols are executed). In this event the real
tree node ID is used (e.g. "0:1").

This works fine except for the first toggle of any node. It fails when I try
to expand a node before at least one node was expanded by clicking on any
"+" symbol. Because it works fine all the other times I think I must
basically be a right way. But why does it fail the first time? 

Despite of debugging the classes and looking at sources I couldn't find out
wether the tree does something special when the first node is being
expanded, maybe some kind of initializing or something.

This is my tree:

          id="shopCategoryTree" value="#{Tree.tree}" 
          var="node" varNodeToggler="t" showRootNode="false"
clientSideToggle="false" showNav="true">

    <f:facet name="category">
        <h:outputLink value="navigation.jsf">
            <h:outputText value="#{node.description}"/>
            <f:param id="categoryId" name="categoryId"


And this is the line of code that manages the state of the tree. This is
part of the backing bean "NavigationBean" which is used for component
binding in the tree above.

     shopCategoryHtmlTree.broadcast( new ToggleExpandedEvent(
this.shopCategoryHtmlTree, "0:1" );

Of course the Id parameter depends on the node that should be expanded but I
thought it makes the example clearer :-))

Can anyone help me answering the questions
- wether this i a adequate approach for toggling nodes programmatically
- why it only works after at least one node is expanded via the component


Thanks a lot in advance. Greetz

View raw message