2 Replies Latest reply on Jul 7, 2009 9:29 AM by iimirela

    rich:tree node selection problem

    iimirela

      Hello,

      I have a rich tree:

      <rich:tree width="300px" value="#{Bean.tree}" var="node"
       switchType="ajax"
       nodeSelectListener="#{Bean.processTreeNodeImplSelection}"
       toggleOnClick="true" onselected="return false">
       <rich:treeNode ajaxSingle="true">
       <h:outputText value="#{node}"/>
       </rich:treeNode>
      </rich:tree>
      


      the listener is:
      public void processTreeNodeImplSelection(final NodeSelectedEvent event) {HtmlTree tree = (HtmlTree) event.getComponent();
       nodeTitle = (String) tree.getRowData();
       selectedNodeChildren.clear();
       TreeNode currentNode = tree.getModelTreeNode(tree.getRowKey());
       if (currentNode.isLeaf()){
       System.out.println("CLICK");
       }
      }
      


      The nodes are loaded dynamcally from the db, which works just fine, the problem is the listener, which is not called when I click on a node (only if I click on the icon), and sometimes gives error ( java.lang.IllegalStateException: No tree element available or row key not set!).

      Richfaces version is 3.3.0, jboss 4.2.3.

      Thank you.

        • 1. Re: rich:tree node selection problem

          In UI do like this...

          <rich:tree switchType="ajax" ajaxSubmitSelection="true"
          toggleOnClick="true"
          nodeSelectListener="#{Bean.processTreeNodeImplSelection}"

          .... >
          why you are using onselected="return false" ? is it for any specific purpose? if not then can remove this.

          In manage bean write method like this..

          public void rocessTreeNodeImplSelection(NodeSelectedEvent event) {

          try {


          UITree tree = (UITree) event.getComponent();
          if(tree!=null){

          if(tree.getTreeNode()!=null){

          nodeTitle = (String) tree.getRowData();
          }
          }
          }catch(Exception ex){

          }
          }

          • 2. Re: rich:tree node selection problem
            iimirela

            Thank you very much. ajaxSubmitSelection="true" did it.

            Ioana.