Uploaded image for project: 'PUBLIC - Liferay Portal Community Edition'
  1. PUBLIC - Liferay Portal Community Edition
  2. LPS-73282 Implement Portlet 3.0
  3. LPS-85475

Portlet 3.0: Distinguish between public and private render parameters that are set on the EventResponse

    Details

      Description

      Portlet 3.0 deprecated the StateAwareResponse.setRenderParameter(String name, String value) method in favor setting values in the MutableRenderParameters returned by the StateAwareResponse.getRenderParameters() method.

      The purpose of these methods was to make it possible for parameters set in the EVENT_PHASE of the portlet lifecycle to survive into the RENDER_PHASE. In Portlet 2.0, parameters set by StateAwareResponse.setRenderParameter(String name, String value) are always treated as private render parameters. But in Portlet 3.0, a distinction between public and private render parameters is necessary.

      For example:

      MyPortlet.java
      public class MyPortlet extends GenericPortlet {
      
          public void processEvent(EventRequest eventRequest, EventResponse eventResponse) {
      
              MutableRenderParameters mutableRenderParameters = eventResponse.getRenderParameters();
              mutableRenderParameters.set("myPublicRenderParam", "1234");
              mutableRenderParameters.set("myPrivateRenderParam", "abcd");
          }
      
          public void doView(RenderRequest renderRequest, RenderResponse renderResponse) {
      
              RenderParameters renderParameters = renderRequest.getRenderParameters();
      
              String myPublicRenderParam = renderParameters.getValue("myPublicRenderParam");
      
              String myPrivateRenderParam = renderParameters.getValue("myPrivateRenderParam");
      
              System.out.println("myPublicRenderParam=" + myPublicRenderParam);
              System.out.println("myPublicRenderParam isPublic=" + renderParameters.isPublic("myPublicRenderParam"));
              System.out.println("myPrivateRenderParam=" + myPrivateRenderParam);
              System.out.println("myPrivateRenderParam isPrivate=" + !renderParameters.isPublic("myPrivateRenderParam"));
          }
      }
      

        Attachments

          Activity

            People

            Assignee:
            brian.chan Brian Chan
            Reporter:
            neil.griffin Neil Griffin
            Recent user:
            Csaba Turcsan
            Participants of an Issue:
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Days since last comment:
              2 years, 44 weeks, 5 days ago

                Packages

                Version Package
                7.1.10 DXP FP3
                7.1.1 CE GA2
                7.1.10.1 SP1
                7.1.X
                Master