Message Boards

PortalUtil.getPlidFromPortletId not working

thumbnail
Randy Leonard, modified 3 Years ago.

PortalUtil.getPlidFromPortletId not working

New Member Posts: 11 Join Date: 2/9/07 Recent Posts
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"%>
    
&nbsp;&nbsp; &nbsp;<liferay-theme:defineobjects />
&nbsp;&nbsp; &nbsp;<portlet:defineobjects />
&nbsp;&nbsp; &nbsp;
&nbsp;&nbsp; &nbsp;&lt;%
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;long myThemeId = themeDisplay.getScopeGroupId();
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;String orgCreatePortletName = com.xyz.portal.masterdata.organization.constants.OrganizationPortletKeys.OrganizationCreate;
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;long orgCreatePlid = com.liferay.portal.kernel.util.PortalUtil.getPlidFromPortletId(myThemeId, orgCreatePortletName);
&nbsp;&nbsp; &nbsp;%&gt;
<liferay-portlet:renderurl var="orgCreateUrl" portletname="<%=orgCreatePortletName%>" plid="<%=orgCreatePlid%>">
&nbsp;&nbsp; &nbsp;<liferay-portlet:param name="productId" value="1234" />
</liferay-portlet:renderurl>

&nbsp;&nbsp; &nbsp;<br>
&nbsp;&nbsp; &nbsp;myThemeId: &lt;%=myThemeId%&gt;
&nbsp;&nbsp; &nbsp;<br>
&nbsp;&nbsp; &nbsp;orgCreatePlid: &lt;%=orgCreatePlid%&gt;
&nbsp;&nbsp; &nbsp;<br>
&nbsp;&nbsp; &nbsp;orgCreatePortletName: &lt;%=orgCreatePortletName%&gt;
&nbsp;&nbsp; &nbsp;<br>
&nbsp;&nbsp; &nbsp;<a href="${orgCreateUrl}">Create new Organization</a>

----
 The Component declaration for the page to which I am generating a link is as follows:    

@Component(immediate = true, property = {
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;"com.liferay.portlet.display-category=" + OrganizationPortletKeys.OrganizationCategory,
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;"com.liferay.portlet.header-portlet-css=/css/main.css",
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;"com.liferay.portlet.instanceable=true",
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;"javax.portlet.display-name=Organization - Create",
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;"javax.portlet.init-param.template-path=/",
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;"javax.portlet.init-param.view-template=/organizationCreate/view.jsp",
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;"javax.portlet.init-param.copy-request-parameters=true",
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;"javax.portlet.name=" + OrganizationPortletKeys.OrganizationCreate,
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;"javax.portlet.resource-bundle=content.Language",
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;"javax.portlet.security-role-ref=power-user,user"
&nbsp;&nbsp; &nbsp;}, service = Portlet.class)
&nbsp;&nbsp; &nbsp;public class OrganizationCreatePortlet extends MVCPortlet

The generated page is as follows, demonstrating an invalid result for PortalUtil.getPlidFromPortletId:    

&nbsp;&nbsp; &nbsp;myThemeId: 20122
&nbsp;&nbsp; &nbsp;orgCreatePlid: 0
&nbsp;&nbsp; &nbsp;orgCreatePortletName: com_xyz_portal_masterdata_organization_OrganizationCreatePortlet

The result I am getting for PortalUtil.getPlidFromPortletId() is zero, which should not be the case.  The resulting link to the intended page does not work.

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
thumbnail
Olaf Kock, modified 3 Years ago.

RE: PortalUtil.getPlidFromPortletId not working

Liferay Legend Posts: 6403 Join Date: 9/23/08 Recent Posts
Randy Leonard:

I am attempting to create a link from one portlet to another, where the two portlets reside in different pages. 
You know, refusing to link crossposts is even worse than not linking them. Because crossposts generate duplicate work for volunteers that don't know your question has been answered elsewhere.

But, as on one of your crossposts, you state
Randy Leonard on an unlinked crosspost:
Could you please stop responding to my posts. Just ignore my post if you are so upset I decided to do an experiment on which of two platforms is best for Liferay questions.

I thought it would only be a fair comparison of the platforms if people on both sides knew that your problem might have already been covered elsewhere.

Good luck - let us know about the ultimate platform
thumbnail
Randy Leonard, modified 3 Years ago.

RE: PortalUtil.getPlidFromPortletId not working

New Member Posts: 11 Join Date: 2/9/07 Recent Posts
why are you being this way... your comments on StackOverflow have been thankfully removed. But you just won't stop.
thumbnail
Olaf Kock, modified 3 Years ago.

RE: PortalUtil.getPlidFromPortletId not working

Liferay Legend Posts: 6403 Join Date: 9/23/08 Recent Posts
Randy Leonard:

why are you being this way... your comments on StackOverflow have been thankfully removed. But you just won't stop.

Here's a quick explanation, if that didn't come through well enough in the stackoverflow meta post that I've linked at your stackoverflow crosspost:

You've crossposted the identical question to multiple sites. You're asking volunteers to help you for free. And we all are happy to provide that free support.
But as soon as a crosspost happens, which doesn't link to the other crossposts, you're generating duplicate work: People in one place are not aware of answers in the other place. Nor do they know additional questions/clarifications from the other site. But we're all providing our support for free. As a minimum courtesy towards your unpaid supporters, is it asked too much to be made aware that the question might be answered already?
And if you don't care about the people potentially helping you: Consider those with a similar question that come after you. They might just find one of the locations - and if that's the one without an answer, and without a link to the crosspost(s), they will get unnecessarily frustrated.
Personally, I've decided to disengage as soon as I see a crosspost, for the reasons stated above, and there are enough questions available that respect free support, that I'd rather concentrate on them.
Sometimes I point to the etiquette (like I did with your posts). Seeing links between crossposts as etiquette or courtesy from your end: Why are you being this way? Don't you value the time and effort of people supporting you for free?
thumbnail
Randy Leonard, modified 3 Years ago.

RE: PortalUtil.getPlidFromPortletId not working

New Member Posts: 11 Join Date: 2/9/07 Recent Posts
I have never cross posted in my life, but on this one issue when I got no essentially no views on Stack Overflow.  So I thought I'd try here.  I didn't even think it would be an issue, the term cross-posting never even occurred to me.
And when I get answers to any posts I get, I always share with the community.  Always.
You have been relentless in beating up on me.  I think the solution is that I just stay away from this forum.
thumbnail
Olaf Kock, modified 3 Years ago.

RE: PortalUtil.getPlidFromPortletId not working

Liferay Legend Posts: 6403 Join Date: 9/23/08 Recent Posts
Randy Leonard:

You have been relentless in beating up on me.  I think the solution is that I just stay away from this forum.
Sorry if it felt like I beat you up - I'd say I (persistently) asked to link your crossposts and didn't mean to do anything else but this.
It's not like I don't help (which you can see all over the forums here, and even in another post of yours)
No bad feelings at all on my end. Even my persistent ask is not a bad feeling for me
thumbnail
Randy Leonard, modified 3 Years ago.

RE: PortalUtil.getPlidFromPortletId not working

New Member Posts: 11 Join Date: 2/9/07 Recent Posts
I don't know... I'm sure you are a great guy.  But I'm just exhausted by this.
thumbnail
Randy Leonard, modified 3 Years ago.

RE: PortalUtil.getPlidFromPortletId not working

New Member Posts: 11 Join Date: 2/9/07 Recent Posts
thumbnail
Olaf Kock, modified 3 Years ago.

RE: PortalUtil.getPlidFromPortletId not working

Liferay Legend Posts: 6403 Join Date: 9/23/08 Recent Posts
Randy Leonard:

I've figured this out, the answer is on Stack Overflow.https://stackoverflow.com/questions/63975811/liferay-portalutil-getplidfromportletid-not-working/64041090#64041090

Thank you for linking to the answer to this question.
Everything else aside: This is how crossposts can be valuable: The answer is finally available on both ends.
(my initial reservation was for hidden crossposts - without links. Upvoted on SO ;) )