1 Reply Latest reply on Apr 9, 2008 1:39 PM by Chris Laprun

    wsrp_rewrite usage

    Eric Smith Newbie

      Using JBAS 4.2.2 and Portal 2.6.4. I would like to use the WSRP_REWRITE functionality as described in the reference manual 24.6.1,


      As a result of this, the token to use for rewrite is the WSRP specified "wsrp_rewrite_". If the portlet sets the following response property

      res.setProperty("WSRP_REWRITE","true");
      all occurrences of the wsrp_rewrite_ token in the portlet fragment will be replaced with a unique token (the window id). If the portlet also specifies content to be injected into the header of the page, that content is also subject to this rewrite.

      res.setProperty("HEADER_CONTENT", "
      <script>function wsrp_rewrite_OnFocus(){alert('hello button');}</script>
      ");



      But when I "view page source" of the portlet content after rendering I am still seeing the wsrp_rewrite_ tokens, not the window id replacement. Am I missing something?

       protected void doView(RenderRequest rRequest, RenderResponse rResponse) throws PortletException, IOException, UnavailableException
       {
       rResponse.setContentType("text/html");
       rResponse.setProperty("WSRP_REWRITE","true");
       rResponse.setProperty("HEADER_CONTENT", "<script>function wsrp_rewrite_OnFocus(){alert('hello button');}</script>");
      
       PortletRequestDispatcher prd = getPortletContext().getRequestDispatcher("/WEB-INF/jsp/view.jsp");
       prd.include(rRequest, rResponse);
       }
      

      and view.jsp
      <%@ taglib uri="http://java.sun.com/portlet" prefix="portlet" %>
      
      <portlet:defineObjects/>
      
      <script>
       var wsrp_rewrite_mygrid='TEST REWRITE';
      </script>
      Hello Rewrite Test Portlet
      


      source produced
      ...
      <link rel="icon" type="image/gif" href="/portal-core/themes/renaissance/images/animated_favicon1.gif" />
      
       <!-- insert header content that was possibly set by portlets on the page -->
      <script>function wsrp_rewrite_OnFocus(){alert('hello button');}</script>
      
      </head>
      
      <body id="body">
      
      ...
      
      <script>
       var wsrp_rewrite_mygrid='TEST REWRITE';
      </script>
      Hello Rewrite Test Portlet</div></div></td><td class="portlet-content-right"></td></tr><tr>
      ...
      



        • 1. Re: wsrp_rewrite usage
          Chris Laprun Master

          It appears that this particular part of the documentation is out of date.
          Several things to note:
          * The WSRP_REWRITE property has been removed as this feature should now be performed transparently by Portal.
          * wsrp_rewrite tokens are only used when WSRP is used. If you're not using WSRP, you wouldn't have seen a difference.
          * It seems that you'd like to namespace the elements in your portlet markup. The portlet specification provides for such a requirement:

          response.getNamespace()
          in your portlet code or the
          <portlet:namespace/>
          portlet JSP tag in your JSP-based portlets.

          Hope this helps.