JSF F:阿贾克斯VS监听行动的commandButton [英] JSF f:ajax listener vs commandButton action
问题描述
我很好奇的是执行Ajax调用的这两种方式的区别是:
I'm curious what is the difference between these two ways of executing ajax calls:
<h:commandButton value="Submit" action="#{bean.action}">
<f:ajax execute="@form" render="component"/>
</h:commandButton>
和
<h:commandButton value="Submit">
<f:ajax listener="#{bean.action}" execute="@form" render="component"/>
</h:commandButton>
看来,人们使用第一种方式更频繁,但第二个似乎工作也很不错...
It appears that people use the first way more often, but the second seems to work just fine as well...
推荐答案
第一种方法可以用于导航通过返回字符串
结局而第二个不行。第二种方法将不会调用任何东西,如果客户有JS禁用,而第一种方式优雅地降低。事实上,第一种方式是应用较多。
The first way allows for navigation by returning a String
outcome and the second not. The second way won't invoke anything if the client has JS disabled, while the first way gracefully degrades. Indeed, the first way is used more often.
第二种方法是在组件的唯一方式,也没有一个动作
属性,如&LT; H:selectOneMenu用于&GT;
等等。
The second way is the only way in components which doesn't have an action
attribute, such as <h:selectOneMenu>
and so on.
这篇关于JSF F:阿贾克斯VS监听行动的commandButton的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!