Message Boards

Redirect to a different Liferay page using the action response

Vishnu S Kumar, modified 3 Years ago.

Redirect to a different Liferay page using the action response

Regular Member Posts: 131 Join Date: 7/28/17 Recent Posts
I want to redirect the user from  /page1 to /page2, and pass a value along with it. This value needs to be available to read inside the render class of a different portlet on page2 .  I've tried the following steps and It didn't work.
#1 
actionResponse.setRenderParameter("param", "value"); // also tried addProperty, & setProperty
actionResponse.sendRedirect("/page2");
Without the 'setRenderParameter' the redirect works.
​​​​​​​#2
We used HttpSession and it worked in our DEV. but failed in the clustered PROD env. due the session replication issues. So , we can't depend on the HtttpSession. Moreover, Liferay seems to be against the use of HttpSession , according to this blog.

.:. This user is an unauthenticated user so we can't depend on DB
thumbnail
Mohammed Yasin, modified 3 Years ago.

RE: Redirect to a different Liferay page from the action response

Liferay Master Posts: 591 Join Date: 8/8/14 Recent Posts
Hi,
You can try creating PortletURL with plid of the page you want to redirect and portletname of the portlet where you want to fetch the parameters
PortletURL portletURL = PortletURLFactoryUtil.create(httpRequest ,portletId, plid ,PortletRequest.RENDER_PHASE); 
portletURL.setParameter(name, value);