4 Replies Latest reply on Jan 15, 2008 1:27 PM by cfoushee

    Help..! Tree !!! =/

      I want to mount one tree that it goes to have varios types of icon !
      Example :

      http://livedemo.exadel.com/richfaces-demo/richfaces/tree.jsf;jsessionid=BD766079488DD571AE8B114B44EEDCDF?c=tree


      But this link shows only the code of .jsp


      I am more than two days trying to make this.
      They help me please.
      since already thanks . xD

        • 1. Re: Help..! Tree !!! =/
          maksimkaszynski

          Richfaces demo site source is included in sources.zip file. You can find it on download page.

          • 2. Re: Help..! Tree !!! =/

            But I want to have many nodes, and each one of different them with icon!
            In the example of this site they are not worried very about this !

            I do not know as to decide this!
            not meeting in place some the solution..

            • 3. Re: Help..! Tree !!! =/
              maksimkaszynski

              Both tree and treeNode component have following attributes iconCollapsed, iconExpanded, iconLeaf, icon.
              You can set values for them using EL.
              For example,

              <rich:tree value="#{bean.data}" var="data" icon="#{data.icon}">

              All you need then is to add icon property to your data type.



              • 4. Re: Help..! Tree !!! =/

                I am trying to add the icon to my data, as suggested above but I must be missing something because I keep getting:

                Error getting property 'icon' from bean of type java.lang.String


                Here's my code:

                import org.richfaces.model.TreeNodeImpl;
                
                public class TreeIconNodeImpl extends TreeNodeImpl {
                
                
                 private static final long serialVersionUID = 1L;
                 private String type;
                 private String icon;
                
                
                 public TreeIconNodeImpl(String type, String icon){
                 super();
                 this.type = type;
                 this.icon = icon;
                 }
                
                 public String getType() {
                 return type;
                 }
                
                 public void setType(String type) {
                 this.type = type;
                 }
                
                 public String getIcon() {
                 return icon;
                 }
                
                 public void setIcon(String icon) {
                 this.icon = icon;
                 }
                
                }
                
                


                 public TreeNode getTreeNode() {
                 if (rootNode == null) {
                 loadTree();
                 }
                 return rootNode;
                 }
                
                private void loadTree(){
                
                 rootNode = new TreeNodeImpl();
                
                 // Add the gateway to the root
                 TreeIconNodeImpl gwNode = null;
                 gwNode = new TreeIconNodeImpl("gateway", "/img/net_wired.gif");
                 gwNode.setData("Gateway");
                 rootNode.addChild(1, gwNode);
                
                 int gwCount = 1;
                
                 TreeIconNodeImpl optNode = null;
                 optNode = new TreeIconNodeImpl("option", "/img/app_winamp_small.gif");
                 optNode.setData("Network Settings");
                 gwNode.addChild(gwCount++, optNode);
                
                 optNode = new TreeIconNodeImpl("option", "/img/app_winamp_small.gif");
                 optNode.setData("Wireless Settings");
                 gwNode.addChild(gwCount++, optNode);
                }
                
                



                 <rich:tree style="width:300px" nodeSelectListener="#{gwTreeBean.processSelection}"
                 reRender="selectedNode" ajaxSubmitSelection="true" switchType="client"
                 value="#{gwTreeBean.treeNode}" var="item" icon="#{item.icon}">
                
                 </rich:tree>