0 Replies Latest reply on Sep 25, 2008 11:20 AM by at_friends

    Recursive Tree node not working

    at_friends

      Hi,
      We are trying to list items and their childrens with Recursive Tree node, but it don't show third level. I always see parent and chid but no more depth.

      Item1 --> Item2 --> Item3 --> Item4

      In this case I see only Item1 and Item 2 ie I always see only 2 levels.
      Here is code:-

      <rich:tree style="width:300px" id="itemListTree"
      nodeSelectListener="#{itemListBean.onItemSelected}"
      stateAdvisor="#{treeDemoStateAdvisor}"
      reRender="selectedNode"
      ajaxSubmitSelection="true">
      <rich:recursiveTreeNodesAdaptor roots="#{itemListBean.rootNodes}"
      var="item" nodes="#{item.nodes}" id="xx">
      </rich:recursiveTreeNodesAdaptor>
      </rich:tree>

      ItemListBean has 2 method

      public synchronized IotaTreeNode[] getRootNodes(){
      for(Item m: rootItems)
      nodes.add(new IotaTreeNode(m.getId(), m.getItemName(), this));
      return nodes.toArray(new IotaTreeNode[nodes.size()]);
      }

      public synchronized IotaTreeNode[] getChildNodes(String parentId){
      for(Item m: rootItems)
      nodes.add(new IotaTreeNode(m.getId(), m.getItemName(), this));
      return nodes.toArray(new IotaTreeNode[nodes.size()]);
      }

      public class IotaTreeNode {
      private String nodeId;
      private String nodeName;
      private IotaBackingBean backingBean = null;
      private static IotaTreeNode[] CHILDREN_ABSENT = new IotaTreeNode[0];
      private IotaTreeNode[] children;

      public IotaTreeNode(String nodeId, String nodeName, IotaBackingBean backingBean) {
      this.nodeId = nodeId;
      this.nodeName = nodeName;
      this.backingBean = backingBean;
      }
      public synchronized IotaTreeNode[] getNodes() {
      if (children == null) {
      children = backingBean.getChildNodes(nodeId);
      if(children == null)
      children = CHILDREN_ABSENT;
      }
      return children;
      }
      public String getNodeId() {
      return nodeId;
      }
      public void setNodeId(String nodeId) {
      this.nodeId = nodeId;
      }
      public String toString() {
      return nodeName;
      }
      }


      Any help will be really appreciated. We are kind of stucked on this.