Client-Side Inter Portlet Communication Done Right +

gearsUsing portlets, you are able to develop tiny little applications that are suitable for a small subset of the actual functionality your customer wants. By combining them, they make it possible to create powerful but still modular applications that meet exactly the use cases your customer needs help with.

In theory.

In practice, you will be faced with a problem that is obviously a blind spot of the portlet definition (at least, the “old” JSR-186): how to communicate between portlets. The ability to mix-and-match portlets is key to a truly pluggable application formed of portlets.

To solve the communication problem, we have developed a solution much like the one developed by the folks at liferay, but a bit more tuned and optimized for a fully pluggable solution.

Portlet Services and Invokers

Our implementation follows a simple pattern: Portlets are able to promote services to a page-central instance and can include interaction elements that are used to invoke services that match certain criteria:

  • the type of object the service must be able to handle
  • the type of operation the service offers

Promoting a service to other portlets includes:

  • specifying what type of operation (CREATE/READ/UPDATE/DELETE) is offered
  • a text telling the user what happens when invoking the service
  • the function that should get called on service activation

Using these simple building blocks we can offer users a list of actions that are available for a specific object:

Completely discoupled

The major advantage of our solution is that we do not hard-wire which portlets offers what to other portlets. All you have to do is insert a service invoker into the UI and the framework does the work for you. All people working on the project can work in parallel, the communication overhead is minimal. All the developers must do is offering a portlets services using the framework and give services a name that speaks.

This makes turns our product into a completely customizable platform that fits exactly our users’s needs.

Maximum flexibility

The framework makes splitting up responsibilities between portlets easy and puzzling just the right application for the job together possible. After adding a new portlet to a page, all service menus are automatically updated to offer new services that may have been added by the new portlet.

Service menu

A generated service menu

Service menu for a different set of portlets

Service menu for a different set of portlets

What you see in these screenshots is that depending on which portlets are available, the portlet will offer different actions for an object (for Screenshot 2, the “Ping” portlet was added). All information about which services are available is calculated client-side and for the current setup. Adding a new portlet will add its services to the actions list. The text that appears inside the menu is set by the portlet offering the service.

Service menu and service button

Invoking services is not limited to the context menus. We also use buttons for services that enable the creation of new items.

Impacts on portlet design

All this makes it easy to develop portlets that are designed to fulfill small tasks the right way. Reusability of portlets is massively increased. And on top of all this you get a consistent usage pattern that your customers will be familiar with when you are adding more functionality.


This is the third article in my mini-series about developing highly ajaxified portlets. In this blog, you can also find articles about:

In my next post in this series, i will give a little insight into how we use metadata generated by our server to make creating a fully ajax portlet a breeze. Meanwhile, check out our posts about testing our Ajax frontends using Selenium and the YUI Test framework.

8 Responses to “Client-Side Inter Portlet Communication Done Right”

  1. Very nice high level overview. I’m assuming there’s more “meat” on the liferay link, as well as your other articles, but when I tried it I got an error saying their blogs were unavailable. Anything from there that we have “got” to know that you can relate to us?

  2. You are right, the link did not work any more. I have updated it, so try the link again if yu want to read more on the topic.

    The corresponding Liferay Wiki page can be found here.

    Basically, they are using an event-based approach as we do, but we have more infrastructure built around the pattern (menu and button generation, an object and action type system etc.) to make things easier to use.

  3. Nice article. Are you going to contibute your js Framework – or at least the clientside IPC js?

  4. Thanks. Yes, this is exactly what we are up to. In fact, it would be helpful if you can express your interest in our solution in the liferay wiki where we proposed to donate our code to the Liferay project:

    Just add a comment :-)

  5. [...] Inter Portlet Communication [...]

  6. [...] Client-Side Inter-Portlet-Communication: Trigger actions between the portlets’ service menus on data items [...]

  7. [...] Inter Portlet Communication [...]

  8. I have made javascript library for portlet programming. It’s name is jQuery.portlet, it also makes portlet to portlet communication possible.

    It can be found at.

    http://code.google.com/p/jquery-portlet/

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>