A common question and topic when I do training or work on support cases, is, "What is the right way to do inter portlet communication in Liferay?"
Well, there is no "right way" to do this. At least not yet. This is because IPC was left out of JSR-168. In other words, there is no standard API. As for JSR-286, there will be a IPC standard that will be an event system. IPC is on the Liferay roadmap as well.
For the time being, here are three ways in which IPC can be implemented:
Method 1) The first is to use the request attributes to pass messages between portlets. You can also use session attributes for this as well.
Method 2) We provide a proprietary portlet url tag that allows you to target one portlet to another (cross-linking). It looks something like this:
<liferay:actionURL portletName="xxx" />
Method 3) Use our AJAX toolkit to inject content from one portlet to another. See http://wiki.liferay.com/index.php/Ajax_Toolkit for more information. You can see how you can use this in conjunction with portlet urls to inject content into a div layer.
The most recommended approach is to use (Method 1) from above, using request or session attributes.
In order for this to work you must have the portlet calling request.setAttribute() and it needs to be doing it within processAction(), so that this executes before the other portlets call render().
Once you do this IPC is complete, the other portlets can pick up the message using renderRequest.getAttribute().
In order for this to work you must have the portlet calling request.setAttribute() and it needs to be doing it within processAction(), so that this executes before the other portlets call render().
Once you do this IPC is complete, the other portlets can pick up the message using renderRequest.getAttribute().
AJAX vs. NON-AJAX
You will have to use a non-ajax approach if you want it to be more flexible. So basically, the trade-off is:
1) non-ajax approach is more flexible
2) ajax approach requires hardcoding of the portlet name in the JSP