This content has been marked as final.
Show 4 replies
-
1. Re: Help..! Tree !!! =/
maksimkaszynski Sep 18, 2007 8:24 AM (in response to nightiger)Richfaces demo site source is included in sources.zip file. You can find it on download page.
-
2. Re: Help..! Tree !!! =/
nightiger Sep 18, 2007 9:44 AM (in response to nightiger)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 Sep 18, 2007 10:57 AM (in response to nightiger)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 !!! =/
cfoushee Jan 15, 2008 1:27 PM (in response to nightiger)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>