Portlet Communication

Home Search

Examples about portlet communication are available in tapestry-liferay-demo project (see Basket and Catalog portlets).

Communicate with Render Parameters

This is probably the easiest way to share information between portlets. According to JSR 168, after each action request there will be a render request. Portlet can declare public render parameter during action phase that will be passed by the container during the render request.

If you want your portlet to use render parameter, you have to Configure your portlet to accept render parameters. this is done by using the "supported-public-render-parameter" element in the portlet definition and by providing public render parameter supported by the application

By default for non ajax event, the bridge generate a action url for each event handler. So the following code demonstrate how to generate a render link and how to add parameter to it.

The Constants.PUBLIC_PARAM parameter will be appended to the following render request. The container will automatically discover which parameter is public or not from the portlet descriptor files.

Communicate with Events

JSR 286 Introduced the concept of portlet events to allow loosely coupled communication between portlets. In order to be allowed to send an event to other portlet, a portlet must first define this event in portlet.xml

Portlet can ask the portal to transmit an event by using the method setEvent of the interface stateAwareResponse. This interface is only available form ActionResponse and eventReponse. In other words, you can only send event during action or event phases. Thanks to PortletEventResultProcessor, in a tapestry page you just need to return an object that implements the interface javax.portlet.Event.

First, you will need to request a server side action phase

and the related event handler could be something like

To receive a portlet events, a portlet must first define in the portlet.xml the events that it can process.

To process the event, the portlet just has to declare an event handler for the related event

More in this section