问题描述
我有以下的code:
<h:commandLink action="#{testBean.showSomething}">
Do Stuff
</h:commandLink>
至极我想要做什么(变化testBean这个状态并重新加载它会显示一组不同的div,网页,因为他们的渲染的属性)现在我想使用Ajax来做到这一点,所以我这样做:
wich 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>
然而,这将导致showSomething方法甚至不被调用。恕我直言,我想要做的是相当简单的,但我不能为我的生活弄清楚如何做到这一点。
However this causes the showSomething method to not even be called.IMHO what i want to do is rather simple but i cant for the life of me figure out how to do it.
推荐答案
您需要使用事件=动作
,而不是事件=点击
。你甚至可以完全忽略它。这也就是默认事件的&LT; F:。AJAX&GT;
监听嵌套在一个 UICommand
组件时,在
You need to use event="action"
instead of event="click"
. You could even omit it altogether. It's namely the default event the <f:ajax>
is listening on when nested in an UICommand
component.
<h:commandLink action="#{testBean.showSomething}">
<f:ajax render=":content" />
Do Stuff
</h:commandLink>
这篇关于调用&LT; H:commandLink&GT;使用与其中的操作方法; F:AJAX&GT;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!