Search code examples
parametersliferayportletparam

Liferay portlet param passing to different portlet


So I have googled whole day, got few answers how to do this, and they all fail. Not to mention all solutions were >3yr old. I'm using LR 6.1 CE. Would be grateful for simple working example, because other answers always got me to null value.


Solution

  • There are 2-3 ways to do this, but try this one.

    get the portletSession from the portletRequest. Use setAttribute() method with 3 parameters. The 3rd parameter should be PortletSession.APPLICATION_SCOPE.

    Get the value from the 2nd portlet from the portlet session. Use the same APPLICATION_SCOPE to get it.

    Edit:

    Also you would require to make the value of the following tags as false in liferay-portlet.xml to share parameters

    <private-request-attributes>false</private-request-attributes>
    <private-session-attributes>false</private-session-attributes>
    

    You can read more about these parameters in the DTD.