IPC

Table of Contents

Using IPC with ICEfaces

Liferays faces bridge taken over portletfaces project
NOTE that the portletfaces bridge project was taken over by Liferay on April 3, 2012 – see https://dev.liferay.com/pt/develop/tutorials/-/knowledge_base/6-2/migrating-from-portletfaces-to-liferay-faces
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:

Disabling Ajax

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.

Portlet Bridge Event Handler

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:

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>
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.

© Copyright 2018 ICEsoft Technologies Canada Corp.