0 Replies Latest reply on May 8, 2008 9:07 AM by Christophe Denis

    rich:tree & rich:recursiveTreeNodesAdaptor: expand/collapse

    Christophe Denis Newbie

      Hi all,

      I would like to expand or collapse when selecting a node in the tree (not just, when clicking the little graphic left beside the node).
      I realised that with this code snippets:

      xhtml:

      <rich:tree switchType="ajax"
       icon="img/folder.png" iconLeaf="img/folder.png"
       ajaxSubmitSelection="true" reRender="wholeContent"
       nodeSelectListener="#{fileSystemBean.processSelection}">
       <rich:recursiveTreeNodesAdaptor
       roots="#{fileSystemBean.sourceRoots}" var="item"
       nodes="#{item.nodes}" />
       </rich:tree>


      action:
      public void processSelection(NodeSelectedEvent event) {
       UITree tree = (UITree) event.getComponent();
       this.selectedNode = (FileSystemNode) tree.getRowData();
       this.selectedNode.setExpanded(!this.selectedNode.isExpanded());
       try {
       if(this.selectedNode.isExpanded()) {
       tree.queueNodeExpand((TreeRowKey)tree.getRowKey());
       } else {
       tree.queueNodeCollapse((TreeRowKey)tree.getRowKey());
       }
       } catch (IOException e) {
       log.error(e);
       // dann eben nicht.
       }
       }


      this works fine, but there is one issue: i can't select a selected node to collapse it (the action isn't called). it means that i have to select another node and then reselect the wanted node to collapse it.

      has someone an idea how to resolve this?

      Greetings, Christophe