7 Replies Latest reply on Dec 19, 2009 10:55 AM by Matthias Nott

    dynamic tree and nodeSelectListener

    Smitha Ramaswamy Newbie

      I have a dynamic tree that is retrieving the node text from the database and it works perfectly fine in displaying the parent node and children.
      I am using rich:tree, rich:recursiveTreeNodesAdaptor, rich:treeNode.
      Now I am trying to get the feature of clicking the leafnode to open up the corresponding link. I am trying to use the nodeSelectionListener to implement this feature
      and I see that it is not working in seam implementation. It never calls the node processing method in the bean.


      I did couple of tests:


      1. I tried to use different switchtype and ajaxSubmitSelection option, it did not work.


      2. I tried to use simple rich:tree to get the nodeSelectionListener work outside seam framework, it works.



       <rich:tree style="width:300px" nodeSelectListener="#{simpleTreeBean.processSelection}" 
                          reRender="selectedNode"
                          ajaxSubmitSelection="true"
                          switchType="client"
                          value="#{simpleTreeBean.treeNode}"
                          var="item">
      </rich:tree>




      3. I tried invoking the app in different browser it still doesn't call the nodeSelectListener implementation.


      Any help on getting this work will be appreaciate. I was reading in forum at one of the thread were the problem was similar but I did not see any answer.
      Any alternate solution to get this working.


      Thanks,



      Here is my code:



      <rich:tree switchType="client" nodeSelectListener="#{configurationTreeManager.processSelection}"
                          reRender="selectedNode" ajaxSubmitSelection="true">
      
           <rich:recursiveTreeNodesAdaptor id="config" roots="#{configurationTreeManager.rootNodes}" 
                      var="config"
                      nodes="#{config.childNodes}">
      
                <rich:treeNode>
                     <h:outputText value="#{config.configuration.nodeText}"/>
                </rich:treeNode>
                              
           </rich:recursiveTreeNodesAdaptor>
      
      </rich:tree>






      @Scope(ScopeType.CONVERSATION)
      @Name("configurationTreeManager")
      public class ConfigurationTreeManager {                
      
           public void processSelection(final NodeSelectedEvent event) {
                final HtmlTree tree = (HtmlTree) event.getComponent();
                nodeTitle = (String) tree.getRowData();
                selectedNodeChildren.clear();
                final TreeNode currentNode = tree.getTreeNode(tree.getRowKey());
      
                if (currentNode.isLeaf()) {
                     System.out.println("current tree node is a leaf");
                     
                } else {
                     System.out.println("current tree node is not a leaf");
      
                     
                }
           }
      }