Message Boards

Doubts about redirection

Daniel G, modified 2 Years ago.

Doubts about redirection

Regular Member Posts: 141 Join Date: 3/14/17 Recent Posts

Hi,

 

I am making a portlet, with a combo for selecting fields, and then it has to redirect to another page and show another jsp different. Is it possible?

For instance, I have the portlet in /home, which shows view.jsp, and when a button is pressed, I want that the portlet redirects to /newPage and then shows the newpage.jsp

I try with actionResponse.sendRedirect but I am not able to find a way to specify which jsp shows. Is there any option of select what jsp has to be shown in doView method?

Any ideas would be very appreciated

Thanks in advance

 

thumbnail
Mohammed Yasin, modified 2 Years ago.

RE: Doubts about redirection

Liferay Master Posts: 591 Join Date: 8/8/14 Recent Posts

Hi,

You can form a URL by using PortletURLFactory and redirect to specific page and jsp, You can refer below example

Layout layout = LayoutLocalServiceUtil.fetchLayoutByFriendlyURL(groupId, privateLayout, "/newPage ");

PortletURL portletURL = PortletURLFactoryUtil.create(actionRequest, "yourportletid", layout,PortletRequest.RENDER_PHASE);
portletURL.setParameter("jspPage", "/newpage.jsp");

actionResponse.sendRedirect(portletURL.toString());