liferay6.2-portlet2.0事件处理
来源:互联网 发布:听不懂程序员说的话 编辑:程序博客网 时间:2024/05/20 07:50
在Portlet2.0,你可以使用服务端事件的技术来使用一个事件监听来在portlets 之间共享数据。当使用IPC 表单的时候,portlet容器的行为类似代理和转发事件及转载数据给portlets.这种方法需要转载数据payload必须实现java.io.Serializable接口,因为它也许会把数据发送到处在另外一个WAR下的portlet,而WAR也许运行在一个不同的类转载器里,另外Portlet2.0标准还需要事件在portlet.xml里进行声明。
下面的文本片段,定义了一个IPC事件,该事件在当一个客户在一个订单portlet里被编辑的时候被触发。订单portlets被当作事件发布者来注册。而customersPortlet则处于另一面,作为该事件的监听来注册。当一个客户被编辑在订单portlet的时候,则会发布一个事件,而customersPortlet则会被通知到,并对该事件进行处理。
Web-inf/portlet.xml片段:
<portlet>
<portlet-name>customersPortlet</portlet-name>
<supported-processing-event>
<qname xmlns:x="http://liferay.com/events">x:ipc.customerEdited</qname>
</supported-processing-event>
</portlet>
<portlet>
<portlet-name>bookingsPortlet</portlet-name>
<supported-publishing-event>
<qname xmlns:x="http://liferay.com/events">x:ipc.customerEdited</qname>
</supported-publishing-event>
</portlet>
....
<event-definition>
<qname xmlns:x="http://liferay.com/events">x:ipc.customerEdited</qname>
<value-type>com.liferay.faces.example.dto.Customer</value-type>
</event-definition>
你也可以对一个事件类型,实现自己的BridgeEventHandler,并在portlet.xml里进行注册。如果该处理器在portlet.xml被注册JSR329标准里要求该处理器就必须被激活,以让它处理所需要处理的任意事件。
当客户信息(例如名字)在订单portlet里被修改,则ipc.customerEdited事件则被发送到Customers portlet通过CustomerEditedEventHandler类来处理:
...
import javax.faces.context.FacesContext;
import javax.portlet.Event;
import javax.portlet.faces.BridgeEventHandler;
import javax.portlet.faces.event.EventNavigationResult;
...
public class CustomerEditedEventHandler implements BridgeEventHandler {
....
public EventNavigationResult handleEvent(FacesContext facesContext, Event event) {
EventNavigationResult eventNavigationResult = null;
String eventQName = event.getQName().toString();
if (eventQName.equals("{http://liferay.com/events}ipc.customerEdited")) {
...
}
return eventNavigationResult;
}
....
}
而这里的CustomerEditedEventHandler则需要在portlet.xml里被注册为桥事件处理器:
<init-param>
<name>javax.portlet.faces.bridgeEventHandler</name>
<value>com.liferay.faces.example.event.CustomerEditedEventHandler</value>
</init-param>
- liferay6.2-portlet2.0事件处理
- Liferay6.0安装笔记
- Liferay6.0+CAS
- liferay6.2导出excel
- liferay6.2通过事件机制实现不同portlet之间数据传递
- Liferay6.0 配置Mysql数据库
- liferay6.2 集成CKEditor和ckfinder
- liferay6.2的开发学习文档
- liferay6.2后台获取input的值
- Liferay6.2开发之FriendlyURL的使用
- liferay6.2开发之索引查询
- Liferay6.2开发之使用Search-Container
- Liferay6.2开发之弹出框
- liferay6.2弹出层,弹出窗
- Liferay6.2开发之FriendlyURL的使用
- liferay6.2 ga6主题工程研究随笔
- [Liferay6.2]Liferay Dynamic Query API示例
- Liferay6.2开发之使用Search-Container
- 开博啦!
- Top 10 JavaScript traps for a C# developer
- poj 3278
- 深入学习JavaScript: apply 方法 详解(转)——非常好
- ztree使用系列四(ztree实现同级拖拽排序并将排序结果保存数据库)
- liferay6.2-portlet2.0事件处理
- bundle开发----数据库访问(基于MySQL)
- GG中obey命令的使用
- 编程实现两个正整数的除法
- ant笔记-2.项目构建的测试java工程
- EJB介绍
- pythonchallenge level8--python2.7
- learn with python-第一章:编程方法
- 45. 腾讯面试题: 使用hashmap 插入数据,怎么样按照插入数据的顺序输出数据