I am attempting to create a link from one portlet to another, where the two portlets reside in different pages. Note the two pages do exist in the same bundle.
I've used this extensively in Liferay 6.x, but identical code is not working in Liferay 7.3.4.
The code I am using to generate this link is as follows:
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet"%>
<%@ taglib uri="http://liferay.com/tld/aui" prefix="aui"%>
<%@ taglib uri="http://liferay.com/tld/frontend" prefix="liferay-frontend"%>
<%@ taglib uri="http://liferay.com/tld/portlet" prefix="liferay-portlet"%>
<%@ taglib uri="http://liferay.com/tld/theme" prefix="liferay-theme"%>
<%@ taglib uri="http://liferay.com/tld/ui" prefix="liferay-ui"%>
<%@ taglib uri="http://liferay.com/tld/util" prefix="liferay-util"%>
<liferay-theme:defineObjects />
<portlet:defineObjects />
<%
long myThemeId = themeDisplay.getScopeGroupId();
String orgCreatePortletName = com.xyz.portal.masterdata.organization.constants.OrganizationPortletKeys.OrganizationCreate;
long orgCreatePlid = com.liferay.portal.kernel.util.PortalUtil.getPlidFromPortletId(myThemeId, orgCreatePortletName);
%>
<br />
myThemeId: <%=myThemeId%>
<br />
orgCreatePlid: <%=orgCreatePlid%>
<br />
orgCreatePortletName: <%=orgCreatePortletName%>
<br />
The Component declaration for the page to which I am generating a link is as follows:
@Component(immediate = true, property = {
"com.liferay.portlet.display-category=" + OrganizationPortletKeys.OrganizationCategory,
"com.liferay.portlet.header-portlet-css=/css/main.css",
"com.liferay.portlet.instanceable=true",
"javax.portlet.display-name=Organization - Create",
"javax.portlet.init-param.template-path=/",
"javax.portlet.init-param.view-template=/organizationCreate/view.jsp",
"javax.portlet.init-param.copy-request-parameters=true",
"javax.portlet.name=" + OrganizationPortletKeys.OrganizationCreate,
"javax.portlet.resource-bundle=content.Language",
"javax.portlet.security-role-ref=power-user,user"
}, service = Portlet.class)
public class OrganizationCreatePortlet extends MVCPortlet
The Liferay project is built using Maven, with the following dependencies found in the pom.xml:
<dependencies>
<dependency>
<groupId>com.liferay</groupId>
<artifactId>com.liferay.asset.taglib</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.liferay</groupId>
<artifactId>com.liferay.comment.taglib</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.liferay</groupId>
<artifactId>com.liferay.frontend.taglib</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.liferay</groupId>
<artifactId>com.liferay.frontend.taglib.dynamic.section</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.liferay</groupId>
<artifactId>com.liferay.frontend.taglib.form.navigator</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.liferay</groupId>
<artifactId>com.liferay.frontend.taglib.util</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.liferay</groupId>
<artifactId>com.liferay.journal.taglib</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.liferay</groupId>
<artifactId>com.liferay.layout.taglib</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.liferay</groupId>
<artifactId>com.liferay.site.taglib</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.liferay.portal</groupId>
<artifactId>com.liferay.portal.kernel</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.liferay.portal</groupId>
<artifactId>com.liferay.util.taglib</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.liferay</groupId>
<artifactId>com.liferay.portal.security.sso.openid</artifactId>
<version>4.0.14</version>
</dependency>
<dependency>
<groupId>javax.portlet</groupId>
<artifactId>portlet-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>jstl</groupId>
<artifactId>jstl</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.service.component.annotations</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
</dependency>
<dependency>
<groupId>org.glassfish.web</groupId>
<artifactId>jstl-impl</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>2.10.3</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.liferay</groupId>
<artifactId>com.liferay.portal.security.sso.openid.connect.api</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>
The generated page is as follows, demonstrating an invalid result for PortalUtil.getPlidFromPortletId:
myThemeId: 20122
orgCreatePlid: 0
orgCreatePortletName: com_xyz_portal_masterdata_organization_OrganizationCreatePortlet
The result I am getting for PortalUtil.getPlidFromPortletId() is zero, which should not be the case.
Again, this used to work just fine my prior projects built with Liferay 6.2. I am not getting the same success with Liferay 7.3.4.
Curious if anyone has had similar issues.
Thanks, Randy
Ok, I figured this out. The following related issue was a bit of a help:
This issue discussed a problem with getPlidFromPortletId working for specific page types, such as Full Page Application.
After some experimenting, it became clear getPlidFromPortletId does not work for portlets embedded within a Content Page, but does work just fine for portlets embedded within a Widget Page.
I'm not sure if this is a bug, or not. But those wishing to use getPlidFromPortletId should use Widget Pages.