Uploaded image for project: 'PUBLIC - Liferay Portal Community Edition'
  1. PUBLIC - Liferay Portal Community Edition
  2. LPS-74443

As a developer, I would like PortalUtil.getPlidFromPortletId to work with Full Page Application pages

    Details

      Description

      Portlets on pages of type "Full Page Application" are not found by PortalUtil.getPlidFromPortletId().

      Use Case

      If I have Portlet A on a page of type "Portlet" and Portlet B on a page of type "Full Page Application" in the same LayoutSet, I want to be able to generate a (friendly) link in Portlet A to the page with Portlet B. It works with the code below if Portlet B is on a page of type "Portlet".

      Steps to reproduce

      1. Create a MVC Portlet with view.jsp (Liferay IDE: Liferay Module Project/Gradle/mvc-portlet)
      2. Include the following code (plus appropriate imports) in view.jsp:
        <%
        long plid = PortalUtil.getPlidFromPortletId(
                        themeDisplay.getScopeGroupId(),
                        "com_liferay_hello_world_web_portlet_HelloWorldPortlet");
        String url = PortalUtil.getLayoutFriendlyURL(
                        LayoutLocalServiceUtil.getLayout(plid), themeDisplay);
        %>
        <a href="<%= url %>">Here's Hello World</a>
        

        EDIT: Fixed JSP closing Tag.

      1. Put this Portlet somewhere on a page.
      2. Put the Hello World Portlet on a different page of type "Full Page Application" in the same Site.

      Expected Behaviour

      The variable "url" and therefore the link inside Portlet A will contain the URL of the page in the same LayoutSet where Portlet B is deployed, even if Portlet B is deployed on a page of type "Full Page Application".

      Actual Behaviour

      LayoutLocalServiceUtil.getLayout(plid) throws an Exception, because plid == LayoutConstants.DEFAULT_PLID after the PortalUtil.getPlidFromPortletId() call.

      Workaround

      Don't use pages of type "Full Page Application". (Sorry, but I don't know better than this. Probably writing something along the lines of PortalImpl.doGetPlidFromPortletId(), if the returned plid equals LayoutConstants.DEFAULT_PLID, but I don't know the equivalent call for LayoutTypePortlet.hasPortletId()...)

      Hints

      The fix probably needs to be done in PortalImpl.doGetPlidFromPortletId() (current master branch: line 7450). Line 7470 only refers to Layouts of type Portlet:

      List<Layout> layouts = LayoutLocalServiceUtil.getLayouts(
      	groupId, privateLayout, LayoutConstants.TYPE_PORTLET);
      

      As far as I can see, that method also needs to heed Layouts of type FullPageApplicationLayoutTypeControllerConstants.LAYOUT_TYPE_FULL_PAGE_APPLICATION or its supertype (if applicable).

      LPS-66092 is related to this bug, but suggests to fix LayoutTypePortletImpl, which seems to me the wrong way to go, since we're not dealing with Layouts of type "Portlet" here...

        Attachments

          Activity

            People

            Assignee:
            hugo.huijser Hugo Huijser
            Reporter:
            david.kliczbor Dave Kliczbor
            Recent user:
            Kiyoshi Lee
            Participants of an Issue:
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:

                Packages

                Version Package
                7.0.X
                7.2.X
                7.3.10 DXP GA1
                Master