Liferay portlet parameter changes to another portlet

So, I have all day googled, I have some answers on how to do this, and they all fail. Not to mention that all decisions were> 3 years old. I am using LR 6.1 CE. I would be grateful for a simple working example, because other answers always led me to a null value.

+4
source share
3 answers

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

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

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

Edit:

You will also need to make the following tags false in liferay-portlet.xml to share parameters

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

You can learn more about these options in the DTD .

+4
source

This code invokes an action from another portlet and sends 2 parameters

you can use:

 liferay-portlet:renderURL liferay-portlet:actionURL <liferay-portlet:actionURL name="addWallEntry" plid="<%= portletId2 %>" portletName="3_WAR_socialnetworkingportlet" var="shareUrl"> <portlet:param name="redirect" value="<%= viewFolderURL.toString() %>" /> <portlet:param name="comments" value="<%= shareMessage %>" /> </liferay-portlet:actionURL> <liferay-ui:icon image="share" url="<%= shareUrl %>"/> 

and you should know the concepts plid: page page link identifier portletName: portlet name with name

The renderURL tool and actionURL are tags provided by Liferay that extend the standard tld. Note: this type of communication is not part of the standard portlets JSR168 and JSR286.

Plid is the identifier of the page on which we deploy one portlet, we can use LayOutLocalService to find the identifier or query directly in the database.

PortletName is the portlet identifier and is part of the portlet deployment descriptor. This identifier consists of portletId + WAR + thenameofwarthatencapsulatestheportlet and, optionally, INSTANCE if the portlet is not valid.

+1
source

I am attaching a demo of a simple liferay-portlet.xml with request and session attributes.

 <?xml version="1.0"?> <!DOCTYPE liferay-portlet-app PUBLIC "-//Liferay//DTD Portlet Application 6.1.0//EN" "http://www.liferay.com/dtd/liferay-portlet-app_6_1_0.dtd"> <liferay-portlet-app> <portlet> <portlet-name>testRedirect</portlet-name> <icon>/icon.png</icon> <instanceable>false</instanceable> <private-request-attributes>false</private-request-attributes> <private-session-attributes>false</private-session-attributes> <header-portlet-css>/css/main.css</header-portlet-css> <footer-portlet-javascript>/js/main.js</footer-portlet-javascript> <css-class-wrapper>testRedirect-portlet</css-class-wrapper> </portlet> <role-mapper> <role-name>administrator</role-name> <role-link>Administrator</role-link> </role-mapper> <role-mapper> <role-name>guest</role-name> <role-link>Guest</role-link> </role-mapper> <role-mapper> <role-name>power-user</role-name> <role-link>Power User</role-link> </role-mapper> <role-mapper> <role-name>user</role-name> <role-link>User</role-link> </role-mapper> </liferay-portlet-app> 
0
source

All Articles