2 Replies Latest reply on Feb 27, 2009 10:53 AM by nbelaevski

    RichTree: Using adviseNodeSelected with nodeSelectListener c

    vigasin

      Hi,

      I've slighlty modified simpleTree from richfaces demo (added adviseNodeSelected). And now always get the following message:


      WARNING: /simpleTree.xhtml @22,63 nodeSelectListener="#{simpleTreeBean.processSelection}": java.lang.IllegalStateException: No tree element available or row key not set!


      Here is the tree:

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


      Here is the code:
       public Boolean adviseNodeSelected(UITree tree) {
       if (nodeTitle.equals((String)tree.getRowData())) {
       return true;
       } else {
       return false;
       }
       }
      


      Steps to reproduce:
      1. Expand some top level node (first of its children will be automatically selected)
      2. Collapse it
      3. Expand it again

      On step 3 nodeSelectListener hook will be called. The exception is thrown when it calls tree.getRowData().

      Why nodeSelectListener is called on node expansion?
      How can I workaround this exception?

      Thank you!