JSF action,actionlistener,onClick之间的区别 [英] JSF difference between action, actionlistener, onClick

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

问题描述

我在项目中使用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.

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

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