permaculture playing cards*
The moose likes JSF and the fly likes Richfaces Tree rich:treeNodesAdaptor not working Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "Richfaces Tree rich:treeNodesAdaptor not working" Watch "Richfaces Tree rich:treeNodesAdaptor not working" New topic

Richfaces Tree rich:treeNodesAdaptor not working

Shen Bg

Joined: Dec 27, 2010
Posts: 2
I am a beginner in Richfaces & Seam. I am trying to render a collection which i fetch from database in tree structure. And on selecting a node I need the value of a column (identifier) of the current object so that I can perform my further action on it. (I need to fetch a row on click of the command link & then render it in a table)I am not sure how to get the identifier in my action class.
Please help!! Any guidance considering my novice approach would be appreciated.

below is my code snippet:
<rich:tree id="ProjectTree" switchType="client">
<rich:treeNodesAdaptor id="projectTreeAdap" nodes="#{simpleTree.savedProjects}" var="prjNode">
<hutputText id="prjName" value="#{prjNode.projectName}"/>
<rich:treeNodesAdaptor id="searchTreeAdap" nodes="#{prjNode.searchResultList}" var="nodes">
<a4j:commandLink id ="savedSearch" value="Saved Searches" action="#{simpleTree.fetchProjects}"/>
<f:param name="projectName" value="prjNode.projectName"/>

Thanks in advance.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15952

There isn't anything really called an "action class" in JSF. But you can attach listener events to tree nodes to be notified when the tree is expanded and contracted.

Actual click events on the nodes can be handled by making them commandLinks. If you want to keep the tree and update contents, use the RichFaces AJAX functions just as you would for a non-tree link that caused a partial page update.

Customer surveys are for companies who didn't pay proper attention to begin with.
Shen Bg

Joined: Dec 27, 2010
Posts: 2
Thanks Tim for your reply.
I solved the problem.However needed one more help regarding rich:treeNodesAdaptor

In rich:treeNodesAdaptor there is an attribute called "nodes" where we can specify a collection through which i want to iterate & display the items in nodes (at the same level). Now the collection that I am using is a List of type of a specific object (entity) which has certain properties. I need to iterate through each of the properties & display them as tree nodes (at same level). But within <rich:treeNodesAdaptor> only one <rich:treeNode> value is rendered as a tree node (for 1 property). If I use multiple such <rich:treeNode> for all the properties, they are never rendered as nodes.
I don't know if my approach is correct but this is all I could figure out till now. Please guide me if you have any idea about this.
Foll is my xhtml code snippet:
<rich:treeNodesAdaptor id="crits" nodes="#{lst.searchCriteria}" var="aaa">
<a4j:commandLink id="critPoly" value="#{aaa.polymer}" action="#{simpleTree.fetchProjects}"/>
<hutputText id="critIndustry" value="#{aaa.industry}"/>
In the above code, like polymer & industry there are 6 more properties that I need to display as nodes, but as of now, only the 1st one, i.e, "aaa.polymer" is rendered as a link, not industry.

Thanks in advance!
I agree. Here's the link:
subject: Richfaces Tree rich:treeNodesAdaptor not working
Similar Threads
Advice on Object data types to use for the rich:tree I am trying to create
Need my rich:tree to be re loaded when I add a new entity to it
richface tree example
need nodes on rich:tree to not be auto selected, only selected when clicked on.
having clicking on a treeNode from rich:tree change ui:define content (need help)