动作、动作侦听器、onClick 之间的 JSF 区别 [英] JSF difference between action, actionlistener, onClick
问题描述
我在我的项目中使用 JSF.我正在使用 PrimeFaces 的上下文菜单.我在 p:menuItem
中看到我们有 action
、actionListener
、onclick
方法.所以我的问题是:我什么时候必须使用 action
、actionListner
、onclick
以及执行的顺序是什么?
I am using JSF in my project. I am using a context menu from PrimeFaces. I see in p:menuItem
we have action
, actionListener
, onclick
methods. So my question is: When do I have to use action
, actionListner
, onclick
and what is the order of execution?
推荐答案
onclick
将首先执行.用于调用javascript函数.onclick
will be executed first. It is used to call a javascript function.actionListener
用于对 a
进行 ajax 调用方法.该方法应该具有返回类型void
,该方法要么将ActionEvent
作为参数,要么不带参数;它可以也可用于非 ajax 调用,但页面将被刷新.actionListener
is used when you want to have some ajax call to a
method. That method should have the return typevoid
, the method either take anActionEvent
as argument or no argument; it can also be used for a non-ajax call but then the page will be refreshed.action
用于导航到不同的页面;该方法应该具有返回类型String
.action
is used to navigate to a different page; the method should have the return typeString
.这篇关于动作、动作侦听器、onClick 之间的 JSF 区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!