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

RenderURL's Friendly URL prevents usage of the MVCRenderCommand



      The original discussion of the issue can be seen here.

      By default, <portlet:renderURL> returns the friendly URL string, when able to successfully convert. When using a link that is converted to a Friendly URL, the behavior changes from originally using a MVCRenderCommand.render to using the MVCPortlet.doView (or my override of it as seen below).

      Based on the intention behind Friendly URL, this should not be the behavior and should actually hit the RenderCommand class.

      Here is an example scenario to depict the issue:

      // package/imports
      	immediate = true,
      	property = {
      		"javax.portlet.display-name=Test Portlet",
      	service = Portlet.class
      public class MyExamplePortlet extends MVCPortlet {
      	public void doView(RenderRequest renderRequest, RenderResponse renderResponse)
      			throws IOException, PortletException {
      		_log.error("<><><><><><><> DoView Called <><><><><><><>");
      		super.doView(renderRequest, renderResponse);
      	private static final Log _log = LogFactoryUtil.getLog(MyExamplePortlet.class);
      // package/imports
      		immediate = true,
      		property = {
      		service = MVCRenderCommand.class
      public class MyExampleRenderCommand implements MVCRenderCommand {
      	public String render(RenderRequest renderRequest, RenderResponse renderResponse) throws PortletException {
      		_log.error("<|><|><|><|> MyExampleRenderCommand.render Called <|><|><|><|>");
      		return "/view.jsp";
      	private static final Log _log = LogFactoryUtil.getLog(MyExampleRenderCommand.class);
      <%@ include file="/init.jsp" %>
      	<%-- <b><liferay-ui:message key="exmaple-stuff.caption"/></b> --%>
      	<portlet:renderURL var="myRenderURL">
      		<portlet:param name="mvcRenderCommandName" value="/exampleportlet/view" />
      	<p>The render URL for the portlet: <a href="${myRenderURL}">${myRenderURL}</a></p>
      <?xml version="1.0" encoding="UTF-8"?>
      <!DOCTYPE routes PUBLIC "-//Liferay//DTD Friendly URL Routes 7.0.0//EN" 
      	<!-- Correct verison -->
      		<implicit-parameter name="mvcRenderCommandName">/exampleportlet/view</implicit-parameter>
      		<implicit-parameter name="p_p_lifecycle">0</implicit-parameter>
      		<implicit-parameter name="p_p_state">normal</implicit-parameter>
      		<implicit-parameter name="p_p_mode">view</implicit-parameter>
      	<!-- Intentational incorrect verison (to disable usage of Friendly URL) -->
      		<implicit-parameter name="mvcRenderCommandName">/exampleportlet/view</implicit-parameter>
      		<implicit-parameter name="p_p_lifecycle">0</implicit-parameter>
      		<implicit-parameter name="p_p_state">normal</implicit-parameter>
      		<implicit-parameter name="p_p_mode">view-bad</implicit-parameter>

      Steps to reproduce:

      1. Go to routes.xml and validate it matched the above (the correct version should be commented out).
      2. Build and deploy the module.
      3. Create new page, 1 column, with no portlets for simplicity.
      4. Add the portlet to the page, refresh page.
      5. Click link inside of portlet (an href to the generated renderURL)
        • Checking the log here should validate that the MVCRenderCommand was called last for the unfriendly URL.
      6. Comment out the invalid section and uncomment the valid section in routes.xml
      7. Redeploy, refresh the page with the deployed portlet. The friendly version should be visible.
      8. Click the link, and view logs.


      ... <|><|><|><|> MyExampleRenderCommand.render Called <|><|><|><|>


      ... <><><><><><><> DoView Called <><><><><><><>


          Issue Links



              • Assignee:
                shanon.mathai Shanon Mathai
                shanon.mathai Shanon Mathai
                Participants of an Issue:
                Recent user:
                Esther Sanz
              • Votes:
                0 Vote for this issue
                0 Start watching this issue


                • Created:
                  Days since last comment:
                  3 years, 5 weeks, 6 days ago


                  Version Package