How to remove Public render parameter from jsp or render phase of portlet class

1k views Asked by At

I have two portlets : 1. Blog Portlet. 2. Author Portlet.

  • I used the concept of Public render parameter to send data (say key "urlTitle") from Blog portlet to Author portlet
  • But after sending "urlTitle" from Blog portlet how can I remove the data from Public render parameter
In Blog Portlet
EX code: view.jsp

<portlet:renderURL var="viewEntryURL">
    <portlet:param name="struts_action" value="/blogs/view_entry" />
    <portlet:param name="redirect" value="<%= currentURL %>" />
    <portlet:param name="urlTitle" value="<%= entry.getUrlTitle() %>" />
</portlet:renderURL>

<a href="${viewEntryURL}">Send Data</a>

Now how I can remove "urlTitle" form the public render parameter after data is sent.

Please give feedback. -Thanks in advance

2

There are 2 answers

0
evaldeslacasa On

You could think about the following:

The LiferayPortletURL (the class that models portlet render, action and resource URLs tags) offers a method called setCopyCurrentRenderParameters

https://docs.liferay.com/portal/6.2/javadocs/com/liferay/portal/kernel/portlet/LiferayPortletURL.html#setCopyCurrentRenderParameters(boolean)

which when set to false, avoids copying render parameters, and the URLs are "cleaned" from those.

The caveat with this is that you would need to create a LiferayPortletURL in the back end doing the following:

    LiferayPortletURL renderUrl = PortletURLFactoryUtil.create(
            httpServletRequest,
            themeDisplay.getPortletDisplay().getId(),
            themeDisplay.getPlid(),
            PortletRequest.RENDER_PHASE);
    renderUrl.setCopyCurrentRenderParameters(false);

and after that pass it to your JSP set as an attribute (maybe renderRequest.setAttribute("renderUrl",renderUrl)?). I haven't done this for render URLs, but for resource URLs and it works!

0
Сергей Бортников On

You need to set

javax.portlet.init-param.copy-request-parameters=false 

in your portlet class.