Ui: repeat in o: treeNodeItem

I have a <o:tree> where I show a list of people and each person, that he has children and every child, that he has children, where the level of children is unknown
The data is displayed correctly, but the displayed node is <h:commandLink> , where its action is a java bean function

Java code snippet:

 public class PersonController{ //class Person having List of children //some code public void readChild(double childId){ } //some code } 

Jsf code snippet:

 <o:tree> <o:treeNodeItem> <ui:repeat var="person" value="#{personController.person}"> #{person.id} <ui:repeat var="child" value="#{person.children}"> <h:commandLink value="#{child.id}" action="#{personController.readChild(child.id)}"/> </ui:repeat> </ui:repeat> </o:treeNodeItem> </o:tree> 

Page displayed:

 --person : 1 ----child : 1.1 ----child : 1.2 --person : 2 ----child : 2.1 ----child : 2.2 

The main problem is that when you press #{personController.readChild(child.id)} id child 1.1, a parameterized double childId sent 2.2, where any child element is clicked, the last one is transmitted when, in case all values ​​are displayed correctly

0
source share
1 answer

I am sending paramater f:param instead of the parameter sent by the function

Thus, the identifier is sent properly by each node

Java code snippet:

 public class PersonController{ //class Person having List of children //some code //remove parameter double childId public void readChild(){ // getting parameter Map<String,String> params = FacesContext.getExternalContext().getRequestParameterMap(); String id = Double.parseDouble(params.get("id")); } //some code } 

Jsf code snippet:

 <o:tree> <o:treeNodeItem> <ui:repeat var="person" value="#{personController.person}"> #{person.id} <ui:repeat var="child" value="#{person.children}"> <h:commandLink value="#{child.id}" action="#{personController.readChild()}"> <f:param name="id" value="#{child.id}"/> </h:commandLink> </ui:repeat> </ui:repeat> </o:treeNodeItem> </o:tree> 
0
source

All Articles