6 Replies Latest reply on Dec 9, 2010 5:41 AM by nbelaevski

    how to customize tree icon in richfaces tree

      I wanted to put different icons for icon attribute of richfaces tree  i.e  node icon should change when we click on root node of richtree.

      can anyone suggest how to customize icon  node of rich tree  accoding to collape and expand?

        • 1. Re: how to customize tree icon in richfaces tree

          Hi,

           

          For customization of icon i am suggeting an idea.

           

          <rich:treenode icon="{bean.iconPath}"  .......... id="treenode"

           

          <a4j:support event="onclick or check for patricular event which is assoicated with treenode collape and expand" action="#{bean.action}"   render= "treenode"/>

          </rich:treenode>

           

          -------bean.java-------

           

          public bean

          {

          action()

          {

          iconPath="/my/icon/dynamic.jpg" ;

          }

           

           

          }

          • 2. Re: how to customize tree icon in richfaces tree
            ilya_shaikovsky

            moving thread to RichFaces space.

            • 3. Re: how to customize tree icon in richfaces tree
              kaimattern

              I got the very same problem. I have a rich:tree and its populated with nodes. All nodes have a getIcon method which is bound to the treenode

               

                             <rich:tree style="width:300px"
                                  nodeSelectListener="#{mssMain.processSelection}"

                                  .

                                  .

                                  .

                               <rich:treeNode type="#{item.type}"
                                                iconLeaf="#{item.icon}"
                                                 icon="#{item.icon}" id="treeNode">
                                      <h:outputText value="#{item.stext}"/>
                                      <a:support event="onclick" action="#{mssMain.update}" render="treeNode"/>
                                  </rich:treeNode>

               

              as you can see I already tried the method mentioned above.

               

              Everything is working fine, on nodeSelectListener is changing the icon from the node but its not updated. Once I close the parent of the selected node and reopen it, the icon is displayed correctly.

               

              Anybody know how to change the icon of the tree node on the fly?

               

              best regards,

              Kai

              • 4. Re: how to customize tree icon in richfaces tree
                nbelaevski

                Kai,

                 

                You should set ajaxKeys attribute to a set of row keys that should be updated.

                • 5. Re: how to customize tree icon in richfaces tree
                  kaimattern

                  Hello Nick,

                   

                  thanks for your replay. I'll test that. I figured out another way yesterday evening.

                   

                               <rich:tree style="width:300px"
                                      nodeSelectListener="#{mssMain.processSelection}"
                                      reRender="mssTree,selectedNode" ajaxSubmitSelection="true"
                                      switchType="ajax" value="#{mssMain.treeNode}" var="item"
                                      nodeFace="#{item.type}"
                                      ajaxKeys="#{null}"
                                      id="mssTree">

                   

                   

                  First I thought that might be a hard approach and only tried it out of desperation but its working real nice even with more then hundred nodes and a full exanded tree.

                   

                  But I'll definatly try yours, it looks more feasible.

                   

                  Best regards,

                  Kai

                  • 6. Re: how to customize tree icon in richfaces tree
                    nbelaevski

                    BTW, forgot to say that you can use ajaxNodeKeys (the same set of keys) to update only node without subtree.