wsrp_rewrite usage
esmith1 Apr 9, 2008 11:04 AMUsing 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> ...