Inter Portlet Communication in Liferay - Part 2

One thing that is really nice to do, for example if you use ICEfaces portlets is to use the Liferay Client - Side IPC Feature. It´s pure JavaScript and very easy to use. It uses the following two methods (Liferay 5.1 and above):

  • Liferay.trigger(eventName, data)
  • Liferay.bind(eventName, function, scope)

By using bind, you can bind a javascript function to an event. The function will be called if the event gets fired


 function(event, data){
   var message = data.message;
   //... do important stuff

You can trigger the event by using the 'trigger' function:

Liferay.trigger('your-event', {message: 'Hello IPC - World'});

This allows you to let any portlet that is capable of JavaScript communicate with each other.

If you like this tutorial it would be very nice, if you could click on some of the google ads you see on the right side. It helps me run this block and motivates me ;)

If you have any questions, feel free to leave a comment.