Unable to redirect to other page in liferay

Saleem Khan picture Saleem Khan · May 2, 2014 · Viewed 8k times · Source

I am trying to redirect to other page using java code and don't no why its not getting redirected. the below is the following code

ThemeDisplay themeDisplay = (ThemeDisplay)actionRequest.getAttribute(WebKeys.THEME_DISPLAY);


PortletConfig portletConfig = (PortletConfig) actionRequest.getAttribute("javax.portlet.config");

String portletName = portletConfig.getPortletName();

PortletURL successPageURL = PortletURLFactoryUtil.create(
                actionRequest, portletName+ "_WAR_" + portletName + "portlet", 
                themeDisplay.getPlid(), PortletRequest.RENDER_PHASE);

successPageURL.setParameter("jspPage", LibraryConstants.PAGE_SUCCESS);
actionResponse.sendRedirect(successPageURL.toString());

it's not redirecting to the page. Please help to check if the code is correct or not.

Thanks.

Answer

Saleem Khan picture Saleem Khan · May 8, 2014

the problem it didn't redirect because we have to add a tag in liferay-portlet.xml that tag is

      <action-url-redirect>true</action-url-redirect>

after above line it worked.