【发布时间】:2014-01-14 15:06:51
【问题描述】:
我已经得出结论,如果我将 h:form 放在 foreach 循环中,则无法调用该函数。
如果我将表单放在外部,将按钮放在 foreach 外部,它将调用正确的函数。但是如何通过一个按钮为每一行获得所需的结果,我可以将输入文本作为新值传递给函数?
请注意,getSeriesForPlayerIInfo 可以正常工作
<c:forEach var="list" items="#{serviceSeries.getSeriesForPlayerInfo(club.name, player.stringID, aSerie, calendarBean)}">
<h:form>
<h:outputText value=" #{list[0] }" />
<h:outputText value=" #{list[1] }" />
<h:outputText value="#{serie.getSerieDateString(list[2]) }" />
<h:outputText value="#{list[3]}"/>
<h:outputText value=" #{list[4] }" />
<h:outputText value=" #{list[5] }" />
<h:outputText value=" #{list[6] }" />
<h:inputText value=" #{list[7] }" />
<h:outputText value=" #{list[8] }" />
<h:commandButton action="#{serviceSeries.PlayerSerie}" value="Uppdatera">
</h:commandButton>
</h:form>
</c:forEach>
【问题讨论】:
-
您是否按照我在您的other question 中的建议尝试将
<c:forEach>替换为<h:dataTable>?另外,您需要<h:form>围绕任何更新值/导致操作的内容。 -
真的会改变绑定只包含一个值的问题吗?
-
为什么要将输入组件绑定到视图,以便稍后将其值作为参数传递?只需传递
list[7]作为第二个参数!顺便说一句,在EL中不需要显式调用toString()方法,因为它是由框架调用来显示当前对象值的。 -
仍然无法让方法调用正常工作。动作参数有问题吗?
-
在 list[7] 中发送将不起作用,因为如果我更新文本字段,它将不会延续到 list[7] 它只会传递原始值