JSF F:阿贾克斯VS监听​​行动的commandButton [英] JSF f:ajax listener vs commandButton action

查看:134
本文介绍了JSF F:阿贾克斯VS监听​​行动的commandButton的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很好奇的是执行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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆