1 Reply Latest reply on Mar 4, 2008 5:27 AM by Daniel Soneira

    rich:tree toggleOnClick / expand node with JS

    Daniel Soneira Novice

      Hi,

      I'm having a problem with expanding tree items with ONE click. Here is the situation:

      For folks who don't want to read the long story - is there a way to expand a tree node with javascript on click?

      --- LONG STORY ---

      My tree consists of folders (article categories) which include other categories. An article category without children is a LINK.

      Without toggleOnClick I have to click on the node ICON to open it.
      WITH toggleOnClick="true" the folders expand on clicking on the item TEXT.

      There are two main jsps:
      - shop => to browse through the different categories, showing a list of articles.
      - article_details => to show the details of the article.

      BUT (here is the big problem ;))

      As you can see in the code below the commandLink has the action "shop" which is a specific jsp.

      The tree is always visible. Also when I navigate to the article details.
      If I click on a category LINK in article_details), the page seems to get re-rendered, but the page stays the same (article_details) - instead of "shop". So the action is not executed. This works with toggleOnClick="false".

      But I want to expand the folders on click.

      Any help would be appreciated,

      Daniel

      <rich:tree switchType="server" style="width:100%" toggleOnClick="true" nodeSelectListener="${page$browse.processSelectCategory}">
       <rich:recursiveTreeNodesAdaptor roots="${browseModel.category}"
       var="category"
       nodes="${category.children}"
       includedRoot="${category.active == true}"
       includedNode="${category.active == true}">
       <rich:treeNode>
       <h:commandLink action="shop" value="${category.name}" immediate="true" rendered="${empty category.children}"/>
       <h:outputText value="${category.name}" rendered="${not empty category.children}"/>
       </rich:treeNode>
       </rich:recursiveTreeNodesAdaptor>
       </rich:tree>
      


        • 1. Re: rich:tree toggleOnClick / expand node with JS
          Daniel Soneira Novice

          If anyone has a similar problem... here is how I made it work:

          - use switchtype="client"
          - use toggleOnClick="true"
          - no nodeSelectListener
          - add actionListener to commandLink directly.


           <rich:tree switchType="client" style="width:100%" toggleOnClick="true">
           <rich:recursiveTreeNodesAdaptor roots="${browseModel.categories}"
           var="category"
           nodes="${category.children}"
           includedRoot="${category.active == true}"
           includedNode="${category.active == true}">
           <rich:treeNode>
           <h:commandLink action="shop" actionListener="${page$browse.processSelectCategory}" value="${category.name}" immediate="true" rendered="${empty category.children}"/>
           <h:outputText value="${category.name}" rendered="${not empty category.children}"/>
           </rich:treeNode>
           </rich:recursiveTreeNodesAdaptor>