Jsf 如何知道在ui中单击了哪个元素:重复?
在JSF中,我们可以将Jsf 如何知道在ui中单击了哪个元素:重复?,jsf,facelets,Jsf,Facelets,在JSF中,我们可以将HtmlDataTable绑定到支持bean并获取行数据。但是ui:repeat甚至没有绑定属性。那么,我如何知道在ui:repeat中单击了哪一行(元素)?使用f:setPropertyActionListener <h:form> <ui:repeat value="#{bean.items}" var="item"> <h:outputText value="#{item.value}"> &
HtmlDataTable
绑定到支持bean并获取行数据。但是ui:repeat
甚至没有绑定属性。那么,我如何知道在ui:repeat
中单击了哪一行(元素)?使用f:setPropertyActionListener
<h:form>
<ui:repeat value="#{bean.items}" var="item">
<h:outputText value="#{item.value}">
<h:commandButton value="submit" action="#{bean.submit}">
<f:setPropertyActionListener target="#{bean.item}" value="#{item}"/>
</h:commandButton>
</ui:repeat>
</h:form>
与
私有列表项;
私人物品;
公开作废提交(){
系统输出打印项次(项);
}
或者只是将动作方法放在迭代项中
<h:form>
<ui:repeat value="#{bean.items}" var="item">
<h:outputText value="#{item.value}">
<h:commandButton value="submit" action="#{item.submit}" />
</ui:repeat>
</h:form>
无论哪种情况,您都需要确保在后续请求中保留相同的项
顺便说一句,这两种方法都只适用于h:dataTable
<h:form>
<ui:repeat value="#{bean.items}" var="item">
<h:outputText value="#{item.value}">
<h:commandButton value="submit" action="#{item.submit}" />
</ui:repeat>
</h:form>