ui:在o:treeNodeItem中重复 [英] ui:repeat in o:treeNodeItem
问题描述
我有一个<o:tree>
,我在其中显示人员列表,每个人都有孩子,每个孩子都有孩子,而孩子的水平尚不清楚.
数据可以正确显示,但是显示的节点是<h:commandLink>
,其作用是Java bean函数
I have an <o:tree>
where i am displaying list of persons and each person what it has children and every child what it have children where the level of children is not known
The data is displayed correctly but the displayed node is an <h:commandLink>
where its action is a java bean function
java代码段:
public class PersonController{
//class Person having List of children
//some code
public void readChild(double childId){
}
//some code
}
jsf代码段:
<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>
渲染页面:
--person : 1
----child : 1.1
----child : 1.2
--person : 2
----child : 2.1
----child : 2.2
主要问题是,单击了#{personController.readChild(child.id)}
id子代参数1.1,发送了参数double childId
,其中单击了任何子代参数,最后发送了参数,以防所有值正确显示.
The main problem is that #{personController.readChild(child.id)}
id child 1.1 is clicked the parameted double childId
is sent 2.2 where any child is clicked the last parameter is sent where in case all values are displayed correctly
推荐答案
我发送了参数f:param
而不是函数发送的参数
I send a paramater f:param
instead of the parameter send by the function
通过这种方式,每个节点都可以正确发送ID
In this way the id is send properly by every node
java代码段:
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代码段:
<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>
这篇关于ui:在o:treeNodeItem中重复的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!