1 Reply Latest reply on Apr 10, 2009 6:36 AM by Nick Belaevski

    rich:treeNode doesn't work with treeNodeVar

    Alexey Koloskov Newbie

      Hello!
      The following code doesn't work:

      <rich:tree value="#{testTreeBean.data}" treeNodeVar="item">
       <rich:treeNode
       iconLeaf="images/tree/leaf.gif"
       icon="/images/tree/folder.gif"
       rendered="#{!item.error}">
       <h:outputText value="#{item.data}" />
       </rich:treeNode>
      
       <rich:treeNode
       iconLeaf="images/tree/leaf_e.gif"
       icon="/images/tree/folder_e.gif"
       rendered="#{item.error}">
       <h:outputText value="#{item.data}" />
       </rich:treeNode>
      </rich:tree>
      

      TestTreeBean.java:
       public CustomTreeNode getData() {
       CustomTreeNode root = new CustomTreeNode();
       root.setData("Root");
      
       CustomTreeNode folder1 = new CustomTreeNode();
       folder1.setData("folder1");
       CustomTreeNode folder2 = new CustomTreeNode();
       folder2.setData("folder2");
      
       root.addChild(1, folder1);
       root.addChild(1, folder2);
      
       return root;
       }
      

      CustomTreeNode.java:
      public class CustomTreeNode extends TreeNodeImpl<String> {
      
       private boolean isError;
      
       public boolean isError() {
       return isError;
       }
      
       public void setError(boolean isError) {
       this.isError = isError;
       }
      
      }
      


      After expanding some node the following error is risen:
      javax.servlet.ServletException: javax.el.PropertyNotFoundException: /h1.xhtml @30,30 rendered="#{!item.error}": Property 'error' not found on type org.richfaces.model.TreeNodeImpl

      I.e. during ApplyRequestValuesPhase tree contains TreeNodeImpl nodes, not nodes from value property: CustomTreeNode.

      Why treeNodeVar variable refers to these strange nodes?

      Thank you,
      Alexey