<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <title>Proper method to access a given jsp of the given portlet from any page?</title>
  <link rel="self" href="https://liferay.dev/c/message_boards/find_thread?p_l_id=119785294&amp;threadId=111224517" />
  <subtitle>Proper method to access a given jsp of the given portlet from any page?</subtitle>
  <id>https://liferay.dev/c/message_boards/find_thread?p_l_id=119785294&amp;threadId=111224517</id>
  <updated>2026-04-07T07:04:01Z</updated>
  <dc:date>2026-04-07T07:04:01Z</dc:date>
  <entry>
    <title>RE: Proper method to access a given jsp of the given portlet from any page?</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=111296393" />
    <author>
      <name>旻 吴</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=111296393</id>
    <updated>2025-04-15T00:43:36Z</updated>
    <published>2018-10-24T03:00:54Z</published>
    <summary type="html">Hello Tomas,&lt;br /&gt;&lt;br /&gt;Thank you for the information. Unfortunately we can not use the same approach because we should create the link in the customized email notification sender where there is no portlet request object be found. &lt;br /&gt;&lt;br /&gt;However, it is interesting that you have mentioned:&lt;br /&gt;&lt;blockquote&gt; The API above should add a token into the URL to avoid the &amp;#34;permission&amp;#34; exception.&lt;/blockquote&gt;which is not found in the url created by&lt;br /&gt;&lt;br /&gt;&lt;a href="https://github.com/liferay/liferay-portal/blob/f0cce6caed9c2a5941d592092df11639883e6d4a/modules/apps/calendar/calendar-service/src/main/java/com/liferay/calendar/internal/notification/NotificationTemplateContextFactory.java#L203-L235"&gt;https://github.com/liferay/liferay-portal/blob/f0cce6caed9c2a5941d592092df11639883e6d4a/modules/apps/calendar/calendar-service/src/main/java/com/liferay/calendar/internal/notification/NotificationTemplateContextFactory.java#L203-L235&lt;br /&gt;&lt;br /&gt;&lt;/a&gt;It might be a hint for further research. Thank you.</summary>
    <dc:creator>旻 吴</dc:creator>
    <dc:date>2018-10-24T03:00:54Z</dc:date>
  </entry>
  <entry>
    <title>RE: Proper method to access a given jsp of the given portlet from any page?</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=111274304" />
    <author>
      <name>Tomáš Polešovský</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=111274304</id>
    <updated>2018-10-22T13:47:42Z</updated>
    <published>2018-10-22T13:47:42Z</published>
    <summary type="html">Hi,&lt;br /&gt;&lt;br /&gt;I&amp;#39;m not sure I fully understand. To recap:&lt;br /&gt;1, you created your own portlet&lt;br /&gt;2, you want to display your portlet on some layout&lt;br /&gt;3, and set some URL parameter, for example MVC path&lt;br /&gt;&lt;br /&gt;Correct?&lt;br /&gt;&lt;br /&gt;Try to use com.liferay.portal.kernel.portlet.PortletURLFactory ... example: https://github.com/liferay/liferay-portal/blob/f1fac9af80650989a8230af8436c52f3d349fe1d/modules/apps/password-policies-admin/password-policies-admin-web/src/main/java/com/liferay/password/policies/admin/web/internal/portlet/configuration/icon/AssignMembersPortletConfigurationIcon.java#L67-L83&lt;br /&gt;&lt;br /&gt;Don&amp;#39;t forget to set MAXIMIZED, EXCLUSIVE or POP_UP state so that the portlet is visible!&lt;br /&gt;&lt;br /&gt;Btw. if you want to display the portlet on any page, including those where it&amp;#39;s not present, then you need &amp;#34;com.liferay.portlet.add-default-resource=true&amp;#34;. The API above should add a token into the URL to avoid the &amp;#34;permission&amp;#34; exception.&lt;br /&gt;&lt;br /&gt;HTH.</summary>
    <dc:creator>Tomáš Polešovský</dc:creator>
    <dc:date>2018-10-22T13:47:42Z</dc:date>
  </entry>
  <entry>
    <title>RE: Proper method to access a given jsp of the given portlet from any page?</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=111238114" />
    <author>
      <name>旻 吴</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=111238114</id>
    <updated>2025-04-15T00:43:36Z</updated>
    <published>2018-10-18T15:56:34Z</published>
    <summary type="html">Hello Sandeep. Thank you for your kind response. We have tried adding the metadata &lt;em&gt;add-default-resource &lt;/em&gt;but unfortunately it didn&amp;#39;t work. Is there any other property or configuration we missed?&lt;br /&gt;&lt;br /&gt;The properties of MVCPortlet component are:&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;@Component(    immediate = true,    property = {        &amp;#34;com.liferay.portlet.add-default-resource=true&amp;#34;,&lt;br /&gt;        &amp;#34;com.liferay.portlet.display-category=category.sample&amp;#34;,        &amp;#34;com.liferay.portlet.instanceable=true&amp;#34;,        &amp;#34;javax.portlet.display-name=kview-scheduler&amp;#34;,&lt;br /&gt;        &amp;#34;com.liferay.portlet.header-portlet-css=/css/main.css&amp;#34;,&lt;br /&gt;        &amp;#34;javax.portlet.init-param.template-path=/&amp;#34;,        &amp;#34;javax.portlet.init-param.view-template=/view.jsp&amp;#34;,        &amp;#34;javax.portlet.name=&amp;#34; + KViewSchedulerPortletKeys.KviewScheduler,        &amp;#34;javax.portlet.resource-bundle=content.Language&amp;#34;,        &amp;#34;javax.portlet.security-role-ref=administrator,guest,power-user,user&amp;#34;    },    service = Portlet.class)&lt;/blockquote&gt;</summary>
    <dc:creator>旻 吴</dc:creator>
    <dc:date>2018-10-18T15:56:34Z</dc:date>
  </entry>
  <entry>
    <title>RE: Proper method to access a given jsp of the given portlet from any page?</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=111234875" />
    <author>
      <name>Sandeep Nair</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=111234875</id>
    <updated>2018-10-18T12:56:36Z</updated>
    <published>2018-10-18T12:56:36Z</published>
    <summary type="html">&lt;html&gt;&lt;head&gt;&lt;/head&gt;&lt;body&gt;Hi,&lt;br&gt;&lt;br&gt;Assuming you are using MVCPortlet add the following property in your portlet class&amp;nbsp;&lt;br&gt;&lt;br&gt;&lt;table&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt;&lt;pre&gt;&lt;code&gt;com.liferay.portlet.add-default-resource=true&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;br&gt;See the reference below as to where to place the property.&lt;br&gt;&lt;br&gt;https://dev.liferay.com/en/develop/tutorials/-/knowledge_base/7-0/adding-metadata&lt;br&gt;&lt;br&gt;Regards,&lt;br&gt;Sandeep&lt;/body&gt;&lt;/html&gt;</summary>
    <dc:creator>Sandeep Nair</dc:creator>
    <dc:date>2018-10-18T12:56:36Z</dc:date>
  </entry>
  <entry>
    <title>Proper method to access a given jsp of the given portlet from any page?</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=111224516" />
    <author>
      <name>旻 吴</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=111224516</id>
    <updated>2025-04-15T00:43:36Z</updated>
    <published>2018-10-18T03:00:02Z</published>
    <summary type="html">&lt;p&gt;Hello. &lt;/p&gt;
&lt;p&gt;We created our own calendar displaying portlet and want to redirect
  the event url to a specified jsp file of our calendar portlet. We are
  trying to imitate the behavior of default Calendar portlet's
  notification url generating process but without any sucees.
   Liferay's version is 7.0 dxp . &lt;/p&gt;
&lt;p&gt;We know that the url is generated in &lt;a
    href="https://github.com/liferay/liferay-portal/blob/master/modules/apps/calendar/calendar-service/src/main/java/com/liferay/calendar/internal/notification/NotificationTemplateContextFactory.java"&gt;NotificationTemplateContextFactory.java&lt;/a&gt;'s  &lt;em&gt;_getCalendarBookingURL &lt;/em&gt;method &lt;/p&gt;
&lt;pre&gt;
private static String _getCalendarBookingURL(
            User user, long calendarBookingId)
        throws PortalException {

        Group group = _groupLocalService.getGroup(
            user.getCompanyId(), GroupConstants.GUEST);

        Layout layout = _layoutLocalService.fetchLayout(
            group.getDefaultPublicPlid());

        String portalURL = _getPortalURL(
            group.getCompanyId(), group.getGroupId());

        String layoutActualURL = PortalUtil.getLayoutActualURL(layout);

        String url = portalURL + layoutActualURL;

        String namespace = PortalUtil.getPortletNamespace(
            CalendarPortletKeys.CALENDAR);

        url = HttpUtil.addParameter(
            url, namespace + &amp;quot;mvcPath&amp;quot;, &amp;quot;/view_calendar_booking.jsp&amp;quot;);

&lt;/pre&gt;
&lt;p&gt;which set the&lt;em&gt; p_l_id &lt;/em&gt;of url to the layout id of the first
  page of the default site. When user click the event url, the default
  calendar portlet's /view_calendar_booking.jsp will be rendered in the
  first page of the default site, even if the default calendar portlet
  is NOT in that page. Actually if we replace the &lt;em&gt;p_l_id&lt;/em&gt; to the
  layout id of any page in the guest site, the
  /&lt;em&gt;view_calendar_booking.jsp&lt;/em&gt; will be rendered on that page, no
  matter where the default calendar portlet locates.&lt;/p&gt;
&lt;p&gt;But when we replace the &lt;em&gt;namespace &lt;/em&gt;to our calendar portlet
  and the &lt;em&gt;mvcPath&lt;/em&gt; to the specified jsp file( by creating
  another &lt;em&gt;EmailNotificationSender&lt;/em&gt; and assigning with a high
  service ranking value ), the url failed and resulted in 'You do not
  have the roles required to access this portlet'. It only works if we
  replace the &lt;em&gt;p_l_id &lt;/em&gt;to the layout id of the page where we
  place our calendar displaying portlet. &lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;We tried to created the resource-actions with VIEW permission to
  sitemembers and guests under src/main/resources/resource-actions/ and
  put it in the portlet.properties under src/main/resources but failed
  either.  Is there any hint how can we achieve the goal? Thank you very much.&lt;/p&gt;</summary>
    <dc:creator>旻 吴</dc:creator>
    <dc:date>2018-10-18T03:00:02Z</dc:date>
  </entry>
</feed>
