1 Reply Latest reply on Nov 21, 2007 1:04 PM by meurisse

    How to expand a tree to a specific treeNode

    hager

      Hello, I'm using rich:tree and i want to expand the tree to a specific node.
      i used public Boolean adviseNodeOpened(UITree tree) method, but it does not work!
      this is my method, what's wrong?

      public void nodeSelectListener(NodeSelectedEvent event)
       {
       try {
       UITree tree = (UITree)event.getComponent();
       selectedNode = tree.getTreeNode();
       rowKeySelected = (TreeRowKey) tree.getRowKey();
       tree.queueNodeExpand(rowKeySelected);
       } catch (IOException e) {
       System.out.println("Exception ici "+e.getMessage());
       }
       }
      
       public Boolean adviseNodeOpened(UITree tree) {
      
       if(rowKeySelected !=null)
       {
       try {
       tree.queueNodeExpand(rowKeySelected);
       return Boolean.TRUE;
       } catch (IOException e) {
       System.out.println("Exception ici "+e.getMessage());
       }
       }
       return null;
       }


      the problem is that all the tree is expanded, but i want to expand the tree to the rowKeySelectedNode
      please help me, I'm really desesperate!!!
      thx very much.

        • 1. Re: How to expand a tree to a specific treeNode

          I used a similar code as your nodeSelectListener, but didn't use the adviseNodeOpened method and it's working.

          You specified the nodeSelectListener for the component, right?

          <rich:tree nodeSelectListener="#{yourBean.nodeSelectListener}"
          ...

          Joel