JSF action,actionlistener,onClick之间的区别 [英] 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
.这篇关于JSF action,actionlistener,onClick之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!