Liferays faces bridge taken over portletfaces project
NOTE that the portletfaces bridge project was taken over by Liferay on April 3, 2012.
For this reason, all current development should use the liferay faces bridge
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:
The 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.
Ajax and ActionRequest/ActionResponse
The API for sending an IPC event is provided as part of an ActionRequest/ActionResponse. An Ajax request is processed by the portlet bridge as a ResourceRequest/ResourceResponse. This means that Ajax requests cannot set IPC events. It should also be emphasized that disabling Ajax for this type of interaction will result in a full-page refresh.
To 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:
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
}
}
<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>
<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>