Portlet to Portlet Communication
The first version of the portlet specification, JSR-168/portlet1.0, did not include any support for Inter Portlet Communication. The second version, JSR-286/ portlet2.0, which is supported for IPC Mechanism.
IPC is made easy with JSR-286 to share the data between two portlets. Using IPC mechanisms, we can share the data from ACTION to VIEW phase and VIEW-VIEW Phase.
There are 3 ways to share the data between 2 portlets.
1. Portlet session
2. IPC Mechanisms
2.1 Public Render Parameters
2.3 Client-Side IPC
1. 1. Portlet Session
By default , Each war has its own session and will not be shared with other wars. Liferay provides a mechanism by which Portlets can share session attributes across WARs.
PortletSessionis created for each user per portlet application. This makes the
PortletSessionuseful for communicating all user related information among different portlets in the same portal application.
Step 1: set below attributes in Portlet1
Step 2: To set the Session:
PortletSession session = renderRequest.getPortletSession();
session.setAttribute("sessionValue",some-value , PortletSession.APPLICATION_SCOPE);
Step 3 : Get the Session Value in Portlet2
PortletSession ps = renderRequest.getPortletSession();
String tabNames = (String)ps.getAttribute("sessionValue ",ps.APPLICATION_SCOPE);
2. IPC Mechanism
2.1 Public Render Parameter : IPC ( Inter Portlet Communication) :