调用使用的操作方法
我有以下代码:
<h:commandLink action="#{testBean.showSomething}">
Do Stuff
</h:commandLink>
它执行我想要的操作(更改 testbean 的状态并重新加载页面,该页面将显示一组不同的 div。因为它们的“渲染”属性) 现在我想使用 ajax 来完成此操作,所以我这样做了:
<h:commandLink action="#{testBean.showSomething}">
<f:ajax event="click" render=":content" />
Do Stuff
</h:commandLink>
但是这会导致 showSomething 方法甚至不会被调用。 恕我直言,我想做的事情相当简单,但我一生都无法弄清楚如何去做。
I have the following code:
<h:commandLink action="#{testBean.showSomething}">
Do Stuff
</h:commandLink>
which does what I want (change the state of testbean and reload the page which will show a different set of divs. because of their "rendered" properties)
Now I want to use ajax to accomplish this so I did this:
<h:commandLink action="#{testBean.showSomething}">
<f:ajax event="click" render=":content" />
Do Stuff
</h:commandLink>
However this causes the showSomething method to not even be called.
IMHO what I want to do is rather simple but I can't for the life of me figure out how to do it.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要使用
event="action"
而不是event="click"
。您甚至可以完全省略它。它是
嵌套在UICommand
组件中时监听的默认事件。You need to use
event="action"
instead ofevent="click"
. You could even omit it altogether. It's namely the default event the<f:ajax>
is listening on when nested in anUICommand
component.