JSF action actionListner 详解
https://stackoverflow.com/questions/3909267/differences-between-action-and-actionlistener
actionListenerUse The
And it's supposed to be declared as follows, without any method parentheses:
Note that you can't pass additional arguments by EL 2.2. You can however override the
Note the importance of the parentheses in the argumentless method expression. If they were absent, JSF would still expect a method with If you're on EL 2.2+, then you can declare multiple action listener methods via
Note the importance of the parentheses in the actionUse The
With this method:
Note that when your action method solely returns a string, then you can also just specify exactly that string in the
With this senseless method returning a hardcoded string:
Instead, just put that hardcoded string directly in the attribute:
Please note that this in turn indicates a bad design: navigating by POST. This is not user nor SEO friendly. This all is explained in When should I use h:outputLink instead of h:commandLink? and is supposed to be solved as
See also How to navigate in JSF? How to make URL reflect current page (and not previous one). f:ajax listenerSince JSF 2.x there's a third way, the
The
In Mojarra, the
But in MyFaces, it would throw a
Ajax listeners are not really useful on command components. They are more useful on input and select components
For explanation on Invocation orderThe
Will invoke the methods in the following order:
Exception handlingThe If the sole reason to use an In ajax requests, however, a special exception handler is needed. This is regardless of whether you use |
跳转的几个方法:
You can do it in two ways:
- Navigation:
Calling an action, with the commandButton component set as ajax false, and the bean method returning a String (as you already have).
xhtml page:
<p:commandButton id="savebutton" ajax="false" value="#{msg['addCategory.save']}" action="#{addCategoryController.doSave()}" />
- Redirect:
Calling an actionListener, with the commandButton component set as ajax true, with the bean method not returning value, but instead performing itself the redirection to the desired page.
xhtml page:
<p:commandButton id="savebutton" ajax="true" value="#{msg['addCategory.save']}" actionListener="#{addCategoryController.doSave()}" />
java bean:
public void doSave(){
categoryAddEvent.fire(categoryProducer.getSelectedCategory());
FacesContext.getCurrentInstance().getExternalContext().redirect(Pages.LIST_CATEGORIES);
}
JSF action actionListner 详解的更多相关文章
- JAVAEE学习——struts2_01:简介、搭建、架构、配置、action类详解和练习:客户列表
一.struts2是什么 1.概念 2.struts2使用优势以及历史 二.搭建struts2框架 1.导包 (解压缩)struts2-blank.war就会看到 2.书写Action类 public ...
- Struts2-整理笔记(二)常量配置、动态方法调用、Action类详解
1.修改struts2常量配置(3种) 第一种 在str/struts.xml中添加constant标签 <struts> <!-- 如果使用使用动态方法调用和include冲突 - ...
- Android 广播大全 Intent Action 事件详解
Android 广播大全 Intent Action 事件详解 投稿:mrr 字体:[增加 减小] 类型:转载 时间:2015-10-20我要评论 这篇文章主要给大家介绍Android 广播大全 In ...
- JSF标签大全详解
1. JSF入门 藉由以下的几个主题,可以大致了解JSF的轮廓与特性,我们来看看网页设计人员与应用程序设计人员各负责什么. 1.1简介JSF Web应用程序的开发与传统的单机程序开发在本质上存在着太多 ...
- Action Bar详解
Action bar是一个标识应用程序和用户位置的窗口功能,并且给用户提供操作和导航模式.在大多数的情况下,当你需要突出展现用户行为或全局导航的activity中使用action bar,因为acti ...
- Android Action Bar 详解篇 .
作者原创,转载请标明出处:http://blog.csdn.net/yuxlong2010 作为Android 3.0之后引入的新的对象,ActionBar可以说是一个方便快捷的导航神器.它可以作为活 ...
- struts2的action类详解
Action类的书写方式 方式1
- Action Bar详解(二)
在Android3.0之后,Google对UI导航设计上进行了一系列的改革,其中有一个非常好用的新功能就是引入的ActionBar,他用于取代3.0之前的标题栏,并提供更为丰富的导航效果. 一.添加A ...
- PyQt(Python+Qt)学习随笔:Action功能详解及Designer中的操作方法
老猿Python博文目录 老猿Python博客地址 一.引言 Qt Designer中的部件栏并没Action相关的部件,Action可以在右侧的Action Editor中编辑,如图: 如果没有出现 ...
随机推荐
- MyEclipse10 复制之前的项目部署到tomcat时项目名称对不上,还是复制前的项目名称,哪里修改设置
工程 -- 右键属性 -- Myeclispse -- web修改一下发布名字就可以了.
- [转帖]cnblog 新闻 : 亚太云计算市场报告:腾讯位列前五 份额首超谷歌
亚太云计算市场报告:腾讯位列前五 份额首超谷歌 投递人 itwriter 发布于 2019-03-18 12:06 评论(1) 有213人阅读 原文链接 [收藏] « » 美国市场研究机构 Syner ...
- java中去除字符串(String)中的换行字符(\r \n \t)
例1: public class Test { public static void main(String[] args) { String s = "'sds gdasda" ...
- FindBugs-IDEA插件的使用
前言 Findbugs很多人都并不陌生,Eclipse中有插件可以帮助查找代码中隐藏的bug,IDEA中也有这款插件.这个插件可以帮助我们查找隐藏的bug,比较重要的功能就是查找潜在的null指针. ...
- centos7系统管理和运维实战——运维必备的网络管理技能(1)
运维必备的网络管理技能 一.网络管理协议: 1.简单的两个概念: DHCP(动态主机配置协议):如果网络结构要更改,需要从新初始化网络参数,手机用动态主机配置协议可以避免这个问题.客户端可以从D ...
- InnoDB: Error: Table "mysql"."innodb_table_stats" not found.
问题:打开mysql错误日志时发现大量的如下错误 Error: Table "mysql"."innodb_table_stats" not found. In ...
- Lodop输出页面input文本框的最新值
默认使用Lodop打印页面上的文本框等,会发现虽然页面上文本框输入了值,打印预览却是空的,这是由于没有把最新的值传入Lodop. 如图,演示的是Lodop如何输出文本框内的新值,这里整个页面只有inp ...
- Linux下git的使用——将已有项目放到github上
本地已经有一个项目了,需要将该项目放到github上,怎么操作? 步骤: 本地安装git,有github账号是前提. (1)先在github创建一个空的仓库,并复制链接地址.使用https,以.git ...
- 目前市场上有些什么样的数据库管理系统(DBMS),它们都有什么特点?它们之间的优缺点有什么?它们的使用场合分别是?
1 要求 目前市场上有些什么样的数据库管理系统(DBMS),它们都有什么特点?它们之间的优缺点有什么?它们的使用场合分别是? 1.1 目前市场上有些什么样的数据库管理系统(DBMS) 目前市场上的数据 ...
- memcached安装报错 error while loading shared libraries: libevent-2.0.so.5: cannot open shared object file: No such file or directory解决
我是从其他服务器scp来的memcached(~~~整个文件夹的那种,windows用多了的后遗症) 在准备运行 ./memcached -d -u root -l localhost -m 800 ...