Using IPC with ICEfaces
The documentation in this section pertains specifically to use of the pre-2012 PortletFaces Bridge. If you are using the Liferay Faces Bridge, this documentation does not apply. Separate documentation for that bridge will be provided at a future date. IPC or inter-portlet communication is a feature of the Portlet 2.0 specification that allows the sending and receiving of custom event between portlets. The portlet bridge makes it possible to use this features with JSF and ICEfaces with certain constraints. In order to use standard IPC with ICEfaces and the PortletFaces Bridge, you need to do the following: Disabling AjaxThe component interaction that triggers the sending of an IPC event needs to have Ajax disabled so that the request is processed as an ActionRequest rather than a ResourceRequest. This can be done in several different ways. Refer to the section on Disabling Ajax for more detailed information.
Portlet Bridge Event HandlerTo enable the portlet bridge to properly handle and direct incoming events, you need to provide and configure a BridgeEventHandler. The portlet bridge will use instances of this class and forward incoming events to it. This requires two things: 1) Create a class that implements the BridgeEventHandler interface. For example: package org.icefaces.sample.portlet; import org.portletfaces.bridge.BridgeEventHandler; import org.portletfaces.bridge.event.EventNavigationResult; import javax.faces.context.FacesContext; import javax.portlet.Event; public class IPCEventHandler implements BridgeEventHandler { public IPCEventHandler(){} public EventNavigationResult handleEvent(FacesContext facesContext, Event event) { //Put event processing code here } } 2) Configure the portlet that needs to receive the messages to use the event handler. This is done by specifying an init-param with the standard key for the BridgeEventHandler and the fully qualified name of the class that implements the interface: <portlet> <portlet-name>my-receiving-portlet</portlet-name> ... <init-param> <name>javax.portlet.faces.bridgeEventHandler</name> <value>org.icefaces.sample.portlet.IPCEventHandler</value> </init-param> ... </portlet> 3) The rest of the configuration involves standard IPC settings. How you add them may depend on the portal container you are running on. On Liferay, you modify the portlet.xml file and add the appropriate settings. For instance, in the portlet.xml file, you define your events and which portlets create and consume them: <portlet-app> <!-- Portlet configured to send events --> <portlet> <portlet-name>my-sending-portlet</portlet-name> ... <supported-publishing-event> <qname xmlns:x="http://mycompany.com/events">x:chatMessage</qname> </supported-publishing-event> ... </portlet> <!-- Portlet configured to receive events --> <portlet> <portlet-name>my-receiving-portlet</portlet-name> ... //Handler defined for incoming events <init-param> <name>javax.portlet.faces.bridgeEventHandler</name> <value>org.icefaces.sample.portlet.chat.ChatEventHandler</value> </init-param> ... <supported-publishing-event> <qname xmlns:x="http://mycompany.com/events">x:chatMessage</qname> </supported-publishing-event> ... </portlet> <!-- Event definition --> <event-definition> <qname xmlns:x="http://mycompany.com/events">x:chatMessage</qname> <value-type>java.lang.String</value-type> </event-definition> </portlet-app> |
IPC
© Copyright 2021 ICEsoft Technologies Canada Corp.