« Back

Liferay JSF Inter Portlet Communication

Liferay Inter portlet communication(IPC) is the mechanism by which one portlet communicates with another portlet. Basically IPC events mechanism is one of the ways to make inter portlet communication among the portlets and these portlets may be in same page or different pages in the portal.
Liferay supports event based IPC which was introduced in JSR 286. According to JSR 286, a portlet can generate event and another portlet can receive the event. JSR-286 makes it easy to share the data between two portlets.
You may find number of blogs/articles related to Liferay mvc portlet communication from the internet. Here I’m going to show you how JSF portlets can communicate with each other on Liferay platform.
I’m assuming that you have knowledge of JSF portlet working on Liferay platform. So, I will directly show you how the event based IPC mechanism works for JSF portlets.
Below are the configurations for generating and receiving event. A portlet can generate and receive any number of events. portlet.xml is the file where we have to define events.
Generate event by Portlet 1 :
Here’s a snippet from the Books portlet’s portlet.xml descriptor:




<qname xmlns:x="http://liferay.com/events">x:ipc.bookSelected</qname>







<qname xmlns:x="http://liferay.com/events">x:ipc.bookSelected</qname>



Receive event by Portlet 2 :
In this portlet the code snippet is similar to above portlet except this portlet process the event.




<qname xmlns:x="http://liferay.com/events">x:ipc.bookSelected</qname>







<qname xmlns:x="http://liferay.com/events">x:ipc.bookSelected</qname>



Here, supported-publishing-event tag use to publish/generate the event and supported-processing-event tag use to process/receive the event.
A QName is a qualified name contains namespace and event name to distinguish two events. Here the namespace is http://liferay.com/events and event name is x:ipc.bookSelected.
Using event-definition we can define the payload type at both generator and receiver side. Here, the type is a custom Java class(Book); it could have also been a primitive type or any standard class. These event definitions require you to use qname to uniquely identify the event. You can define multiple events in portlet.xml file.
Portlet 1 (Generate the event) :
Code snippet of view.xhtml

<h:form id="books-form">

<h:dataTable value="#{booksModelBean.allBook}" var="book">


<h:commandButton actionListener="#{booksBackingBean.selectionListener}" value="#{book}" />




Code snippet of BooksBackingBean.java

@ManagedBean(name = "booksBackingBean")


public class BooksBackingBean implements Serializable {

public void selectionListener(ActionEvent actionEvent) {

UICommand uiCommand = (UICommand) actionEvent.getComponent();

Book book = (Book) uiCommand.getValue();

QName qName = new QName(“http://liferay.com/events”,”ipc.bookSelected”);

ExternalContext eCon = FacesContext.getCurrentInstance().getExternalContext();

ActionResponse actionResponse = (ActionResponse) eCon.getResponse();

Serializable eventPayload = book;

actionResponse.setEvent(qName, eventPayload);



Portlet 2 (Receive event) :
Code snippet of portlet.xml









Basically you have to declare which class handle the event processing in portlet.xml file as defined above. Here we have defined that BookSelectedEventHandler class handle the event processing part. So, it needs to implement the method handleEvent of class BridgeEventHandler
Code snippet of BookSelectedEventHandler.java

public class BookSelectedEventHandler implements BridgeEventHandler {

public EventNavigationResult handleEvent(FacesContext facesContext, Event event) {

EventNavigationResult eventNavigationResult = null;

String eventQName = event.getQName().toString();

if (eventQName.equals("{http://liferay.com/events}ipc.bookSelected")) {

Serializable value = event.getValue();

Book book = (Book) value;

// Process event...

String fromAction = null;

String outcome = "ipc.bookSelected";

eventNavigationResult = new EventNavigationResult(fromAction, outcome);


return eventNavigationResult;



Here, we take the example of Library Management.
Above image shows two portlets. One portlet contains book list and another portlet handle book creation/updation part. Both portlet communicate and share the data using event mechanism. I have attached two war files of both portlet at the end of this article.
Download :
Sriram v
Does this IPC works for Portlets residing in different page ?
Posted on 2/29/16 6:02 PM.
Chirag Patel
IPC mechanism describe in this article works for Portlets residing in the same page.

But IPC mechanism can be possible for portlets residing in different pages. It will just need some more configurations.
Posted on 3/3/16 6:41 AM in reply to Sriram v.

Contact Us

For your business requirements


Get in touch

Headquarter : 302, Landmark, Nr. Titanium City Center, Prahlad Nagar Road, Ahmedabad, India - 380015.

Showing 1 - 5 of 20 results.
of 4
contact-us Request a callback