动作、动作侦听器、onClick 之间的 JSF 区别 [英] JSF difference between action, actionlistener, onClick

查看:20
本文介绍了动作、动作侦听器、onClick 之间的 JSF 区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的项目中使用 JSF.我正在使用 PrimeFaces 的上下文菜单.我在 p:menuItem 中看到我们有 actionactionListeneronclick 方法.所以我的问题是:我什么时候必须使用 actionactionListneronclick 以及执行的顺序是什么?

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 type void, the method either take an ActionEvent 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 type String.

      这篇关于动作、动作侦听器、onClick 之间的 JSF 区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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