commandButton 不调用 bean 操作方法
我对 JSF2 渲染操作有一个大问题。 我使用简单的 c:forEach 来迭代列表。这个列表有 itens,这些项目有一个包含更多 Itens 的列表。所以它是一个嵌套的 c:forEach。子列表有一个输入字段,一旦保存,必须转到 bean,保存这个新输入,然后返回到带有更新列表的屏幕。 没有什么复杂的事情要做。当我调试将列表发送回视图的方法时,我看到所有信息都是正确的。 所以我们来解决这个问题:命令按钮第一次工作正常。但是,如果我在刷新后尝试单击列表上的另一个按钮,则该按钮不会调用我的方法。奇怪的是,该操作确实将其发送到 bean(它通过我的 @PostConstruct 方法),但没有调用我想要的方法。
代码:
<c:forEach var="pub" items="${publicacaoCidadeController.listaPublicacao}" varStatus="status">
<div>message from first list : ${status.count} <br/>
<h:outputLabel value="#{pub.publicacao.mensagem}" />
<br/><br/>message from second list :<br/>
<h:form>
<f:ajax event="action" execute="@form" render="@all">
<c:forEach id="test2" var="com" items="#{pub.publicacao.comentarioList}" >
<div>
<h:outputLabel value="#{com.mensagem}" />
</div>
</c:forEach>
<div>
<h:inputTextarea value="#{publicacaoCidadeController.msgComentarioNovo}" />
<div >
<h:commandButton type="submit" value="Postar" action="#{publicacaoCidadeController.salvarComentario}" >
<f:param name="codPublicacao" value="#{pub.publicacao.codPublicacao}"/>
<f:param name="postNum" value="${status.count}"/>
</h:commandButton>
</div>
</div>
</f:ajax>
</h:form>
</div>
</c:forEach>
大家有什么想法吗?
Im having a big issue with JSF2 render actions.
Im using a simple c:forEach to iterate over a List. This list has itens and those items has a List of more Itens. So its a nested c:forEach. The sub list has an input field that, once saved, has to go to the bean, save this new input, and get back to the screen with the updated List.
Nothing complex to do. When i debug the method that sends the List back to the view, i see that all the information is correct.
So here we go with the issue : The first time the commandButton works fine. But if i try to click on another button on the list just after it was refreshed, the button does not call my method. Whats wierd is that the action does sends it to the bean (it goes thru my @PostConstruct method), but does not call the method i want.
The code :
<c:forEach var="pub" items="${publicacaoCidadeController.listaPublicacao}" varStatus="status">
<div>message from first list : ${status.count} <br/>
<h:outputLabel value="#{pub.publicacao.mensagem}" />
<br/><br/>message from second list :<br/>
<h:form>
<f:ajax event="action" execute="@form" render="@all">
<c:forEach id="test2" var="com" items="#{pub.publicacao.comentarioList}" >
<div>
<h:outputLabel value="#{com.mensagem}" />
</div>
</c:forEach>
<div>
<h:inputTextarea value="#{publicacaoCidadeController.msgComentarioNovo}" />
<div >
<h:commandButton type="submit" value="Postar" action="#{publicacaoCidadeController.salvarComentario}" >
<f:param name="codPublicacao" value="#{pub.publicacao.codPublicacao}"/>
<f:param name="postNum" value="${status.count}"/>
</h:commandButton>
</div>
</div>
</f:ajax>
</h:form>
</div>
</c:forEach>
Any ideas guys?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试使用
ui:repeat
标签。c:foreach
是一个 build-view-tag,ui:repeat
是一个 render-tag。按下命令按钮后,jsf-tree 不会重建...
如果包含
ui:debug
标记,您可以查阅 de jsf-tree 并调查发生了什么...Try to use
ui:repeat
tag.c:foreach
is a build-view-tag andui:repeat
is a render-tag.After pressing the command button the jsf-tree isn't rebuild ...
If you include the
ui:debug
tag, you can consult the de jsf-tree and investigate what's going on....