3 Replies Latest reply on Nov 30, 2009 9:20 AM by Ilya Shaikovsky

    How add links to Tree

    Kushan Jayathilake Newbie

      Hi Guys,

      I have crated a <rich:tree> with backing bean, and have hard coded tree's values like below

       public TreeManagedBean() {
      
       rootAdmin.setData("Administrator");
       rootAccounts.setData("Accounts");
       rootOther.setData("Other");
       rootChangePwd.setData("Change Password");
      
       nodes.addChild(0, rootAdmin);
       nodes.addChild(1, rootAccounts);
       nodes.addChild(2, rootOther);
       nodes.addChild(3, rootChangePwd);
      
       TreeNodeImpl<String> childCompany = new TreeNodeImpl<String>();
       childCompany.setData("Company");
       rootAccounts.addChild(0, childCompany);
      
       TreeNodeImpl<String> childLicence = new TreeNodeImpl<String>();
       childLicence.setData("Licence Management");
       rootAccounts.addChild(1, childLicence);
      
       TreeNodeImpl<String> childFunction = new TreeNodeImpl<String>();
       childFunction.setData("Functions");
       rootAccounts.addChild(2, childFunction);
      
       TreeNodeImpl<String> childRoles = new TreeNodeImpl<String>();
       childRoles.setData("Roles");
       rootAccounts.addChild(3, childRoles);
      
       TreeNodeImpl<String> childCountry = new TreeNodeImpl<String>();
       childCountry.setData("Country");
       rootOther.addChild(0, childCountry);
      
       }
      


      and in JSP

      <rich:tree value="#{treeManagedBean.nodes}" var="node" adviseNodeOpened="true" >
       <rich:treeNode >
       <a4j:commandLink value=""></a4j:commandLink>
       <h:outputText value="#{node}" />
       </rich:treeNode>
      </rich:tree>
      


      Problem is how can load a page once i click the tree node ( add a link there) through backing bean, since backing bean feeds the data to the Tree.

        • 1. Re: How add links to Tree
          Ilya Shaikovsky Master

          you want navigate via links inside the tree? then you could
          1) set ajaxSubmitSelection to false and use h:outputLink or h:commandLink with navigation actions inside.
          2) set ajaxSubmitSelection to true. define body with a4j:include and bind viewId with some EL. Then just manage this EL binding in treeNode action. Then you not need in link inside because treenode will works as link itself.

          • 2. Re: How add links to Tree
            Kushan Jayathilake Newbie

             

            "ilya_shaikovsky" wrote:
            you want navigate via links inside the tree? then you could
            1) set ajaxSubmitSelection to false and use h:outputLink or h:commandLink with navigation actions inside.
            2) set ajaxSubmitSelection to true. define body with a4j:include and bind viewId with some EL. Then just manage this EL binding in treeNode action. Then you not need in link inside because treenode will works as link itself.


            Hi, thanks for replying,

            What i want is, when i click on a particular node in the tree the relevant web page should load. thats all.

            • 3. Re: How add links to Tree
              Ilya Shaikovsky Master

              try 1) approach.