« Back to Development

Inter-portlet communication

Introduction #

The first version of the portlet specification, JSR-168, did not include any support for Inter Portlet Communication. The second version, JSR-286, which is supported by Liferay since version 5 does. This page describes a series of methods that can be used to communicate portlets prior to that version, or that you might prefer to use even after that version. It also includes links to articles with information about the mechanisms introduced in JSR-286.

Standard IPC introduced in JSR-286 (Portlets 2.0) #

JSR-286 introduces two methods of Inter Portlet Communication:

  • Shared render parameters: allows portlets to set params that can be read by other portlets. This rather simple mechanism will probably be enough for all but the most complex communication needs.
  • Events: needed for complex scenarios. The main advantage of this second method is that it allows a fully decoupled communication. A portlet issues an event and doesn't have to care if there is anyone listening for it.

A more detailed description about these two methods an other new features of Portlets 2.0 can be read in What's new in the Java Portlet Specification V2.0 (JSR 286)?.

|The Client side events mechanism #

This is a new mechanism introduced in Liferay v5.0 and provides a very lightweight and decoupled mechanism to communicate portlets purely in the browser through a JavaScript events mechanism.

A full wiki article covers this topic in detail: Client-side Inter-Portlet Communication]

AJAX way#

The pattern is:

You make an ajax call from one portlet and provide this portlet with id in another portlet. When you have an answer from the ajax call you update the div with the information you got.

It would be convenient to route the calls through a container object. Whenever, a portlet is added or removed, it needs to register/un-register itself to the container. The container would refer to the portlet through it's id and the reference to the DIV element.

Session variables sharing #

Another way is to store variables in the session and make them sharable for portlets. This way you can put stuff into session and display different things based on the information in the session. Look here: Sharing session variables

Use Liferay portlet url tag #

Proprietary portlet url tag that allows you to target one portlet to another (cross-linking). It looks something like this

  <liferay-portlet:actionURL portletName="xxx" />

Where "xxx" is the <portlet-name>xxx</portlet-name> of the portlet as defined in the portlet.xml file.

Note that it also needs to include the WAR reference if it is in a portlet war.

e.g. A war named "sample-struts-liferay-portlet" having a portlet with the name "sample_struts_liferay_portlet" will have an fully qualified name as:


Furthermore, if the portlet is instanceable (<instanceable>true</instanceable> in liferay-portlet.xml) it will contain an instance identifier like so:


making the full name:


The end result is a portlet tag like so:

  <liferay-portlet:actionURL portletName="sample_struts_liferay_portlet_WAR_samplestrutsliferayportlet_INSTANCE_im3I" />

You can also look at this topic for discussion and details: http://www.liferay.com/web/guest/community/forums/message_boards/message/272753

0 Attachments
Average (1 Vote)
The average rating is 3.0 stars out of 5.
Threaded Replies Author Date
bump Andre Darian Bonner October 14, 2008 1:55 PM
The information about Inter Portlet... Carlos Santos November 10, 2009 4:18 AM
Could someone elaborate on this more? I am... J B April 9, 2010 12:31 PM
Help! I need a real sample.. Which files I need... Melvin Rodriguez Rojas March 30, 2011 10:44 AM
can someone send to harokidz@gmail.com sample... Pieter Haro July 18, 2011 8:51 PM
http://liferaycms.blogspot.com/2011/07/inter-po... Jignesh Vachhani August 19, 2011 12:20 AM

Posted on 10/14/08 1:55 PM.
The information about Inter Portlet Communication feature of the 2.0 portlet spec could be more explicit.
Posted on 11/10/09 4:18 AM.
Could someone elaborate on this more? I am trying to utilize this using ColdFusion 9 portlets under JBOSS Liferay. And I am starting to pull out hair at this point...

How does a <liferay-portlet:actionURL portletName="sample_struts_liferay_portlet_WAR_samplestrutsliferayportlet_INSTAN­CE_im3I" /> tag help me pass info from one to the other?
Posted on 4/9/10 12:31 PM.
Help! I need a real sample..
Which files I need to edit.???

In portlet 1 how I make the link to call portlet 2..
and in portlet 2 how I capture the call from the portlet 1 ..
Posted on 3/30/11 10:44 AM.
can someone send to harokidz@gmail.com sample how to communicate 2 portlet
Posted on 7/18/11 8:51 PM.
Posted on 8/19/11 12:20 AM in reply to Pieter Haro.