3 Replies Latest reply on Mar 19, 2007 9:55 AM by foures adrien

    rich:tree expands node by default

    foures adrien Newbie

      Hi

      How is it possible to load tree with some node already open by default?
      I try with binding attribute, HtmlTree.

      TreeRowKey key = new TreeRowKey();
      rootNode.getTreeModel().queueNodeExpand(key);

      How can i get a TreeRowKey instance?

      Is there another solution to expand node?

      thanks

        • 1. Re: rich:tree expands node by default
          Dustin Norlander Apprentice

          My understanding is that this is not possible at the moment. (If you figure out how to do this then please let me know)

          http://www.jboss.com/index.html?module=bb&op=viewtopic&t=103725

          -Dustin

          • 2. Re: rich:tree expands node by default
            foures adrien Newbie

            Hi

            I found a begining solution

            HtmlTree ht = new HtmlTree();
            ht.setValue(rootNode); // TreeNode root
            ht.createDataModel();

            // Binding
            HtmlTree sht = (SigemsHtmlTree) ht.getNodeFacet().getUITree();
            TreeState ts = (TreeState) sht.getComponentState();
            ts.expandAll();

            All treenode are open on page load, but i wondering now how can i walk tree to get treeRowKey that i want to open on startup.
            If you have an idea.

            Thank

            • 3. Re: rich:tree expands node by default
              foures adrien Newbie

              And the solution is ...

              RootTreeNode rootNode = new RootTreeNode();
              FirstTreeNode firstNode1 = new FirstTreeNode("f1","first1"); //f1 identifier (also key)
              FirstTreeNode firstNode2 = new FirstTreeNode("f2","first2");
              FirstTreeNode firstNode3 = new FirstTreeNode("f3","first3");

              SecondTreeNode secondNode1 = new SecondTreeNode("s1","second1");
              SecondTreeNode secondNode2 = new SecondTreeNode("s2","second2");
              SecondTreeNode secondNode3 = new SecondTreeNode("s3","second3");
              SecondTreeNode secondNode4 = new SecondTreeNode("s4","second4");
              SecondTreeNode secondNode5 = new SecondTreeNode("s5","second5");
              SecondTreeNode secondNode6 = new SecondTreeNode("s6","second6");

              ThirdTreeNode thirdNode1 = new ThirdTreeNode("t1","third1");
              ThirdTreeNode thirdNode2 = new ThirdTreeNode("t2","third2");


              firstNode1.addSecond(secondNode1);
              firstNode1.addSecond(secondNode2);
              firstNode1.addSecond(secondNode3);

              secondNode4 .addThird(thirdNode1);
              secondNode4 .addThird(thirdNode2);
              firstNode2.addSecond(secondNode4);
              firstNode2.addSecond(secondNode5);

              firstNode3.addSecond(secondNode6);

              rootNode.addFirst(firstNode1);
              rootNode.addFirst(firstNode2);
              rootNode.addFirst(firstNode3);


              HtmlTree ht = new HtmlTree();
              ht.setValue(rootNode);
              ht.createDataModel();
              HtmlTree sht = ht.getNodeFacet().getUITree();

              TreeState ts = (TreeState) sht.getComponentState();
              ts.expandAll();
              ts.collapseAll();

              ArrayList al = new ArrayList();
              al.add("f2");
              ListRowKey lrk = new ListRowKey(al);
              ts.expandNode(lrk);

              al = new ArrayList();
              al.add("f2");
              al.add("s4");
              lrk = new ListRowKey(al);
              ts.expandNode(lrk);