Continuing from my previous article, this article describes the alternate method to share data across multiple portlets, by making use of PortletContext.
One can directly make use of setAttribute(String, Object) method to share data across portlets.
In this method, there's a different catch in this method. A porlet that sets attribute is shared by the portlet, no matter how many times it is used in a page or anywhere. It is even shared by all users. Use this method with caution!
I would suggest using this method when a common notification needs to be shown to others. An example of this would be showing unavailability of a service used by a portlet. Real-life example would be a portlet getting latest news from Yahoo should show an available note when the service becomes unavailable.
Think once again before using inter-portlet communication. Is it really required? Cannot you do without it?
