Fórum

Portlet redirection Liferay pages

thumbnail
Olivier ROMAND, modificado 12 Anos atrás.

Portlet redirection Liferay pages

New Member Postagens: 24 Data de Entrada: 07/01/12 Postagens Recentes
Hey people,

I'm sure it sounds like an easy task, but I haven't found the elements to implement this:
I want a POST action triggered to a portlet to redirect me to a specific page (meaning Liferay page).

I have the search portlet embedded into my theme and link with a <form> tag action. The actions that gets triggered would call the processAction() of my portletClass.
So far so good.

But then, depending on a condition (sent in the parameters), I want to redirect the user on a page rather than another.
A quick drawing is:



I found that this may work, but I can't get it done.

    FacesContext.getCurrentInstance().getExternalContext().redirect("url");


Is it the good way to go ?
thumbnail
Ravi Kumar Gupta, modificado 12 Anos atrás.

RE: Portlet redirection Liferay pages

Liferay Legend Postagens: 1302 Data de Entrada: 24/06/09 Postagens Recentes
After an action method is called, control goes to render/doview method. There it will decide which jsp to render based on our logic.

To call a portlet on a different page.. see this post http://www.liferay.com/community/forums/-/message_boards/message/10158348
thumbnail
Olivier ROMAND, modificado 12 Anos atrás.

RE: Portlet redirection Liferay pages

New Member Postagens: 24 Data de Entrada: 07/01/12 Postagens Recentes
Thanks for the input Ravi.

As we are using JSF with Mojarra, is it possible to call a Liferay page.
I was thinking to use something like this, but can't get it working.


@Override
	public void processAction(ActionRequest actionRequest,
			ActionResponse actionResponse) throws PortletException, IOException {
		
		
		super.processAction(actionRequest, actionResponse);

		actionRequest.setAttribute("searchresults", new String("searchresults"));		
	}

	@Override
	protected void doView(RenderRequest renderRequest,
			RenderResponse renderResponse) throws PortletException, IOException {

		super.doView(renderRequest, renderResponse);
		
		if(renderRequest.getAttribute("searchresults") != null){
			PortletRequestDispatcher prd = getPortletContext().getRequestDispatcher("/my-liferay-page");
		 	prd.forward(renderRequest, renderResponse);	
		}
	}


Any hints ?
thumbnail
Olivier ROMAND, modificado 12 Anos atrás.

RE: Portlet redirection Liferay pages

New Member Postagens: 24 Data de Entrada: 07/01/12 Postagens Recentes
Just found out that this would work.
It somehow sounds like hijacking the whole process .. doesn't it ?



	@Override
	public void processAction(ActionRequest actionRequest,
			ActionResponse actionResponse) throws PortletException, IOException {
		
                 //if...else
		actionResponse.sendRedirect("/my-liferay-page");
		
	}


Ravi, what about the same in doView ?
thumbnail
Ravi Kumar Gupta, modificado 12 Anos atrás.

RE: Portlet redirection Liferay pages

Liferay Legend Postagens: 1302 Data de Entrada: 24/06/09 Postagens Recentes
Hi,
What you did is right. For more can you check this page please http://www.liferay.com/community/forums/-/message_boards/message/493491
thumbnail
Olivier ROMAND, modificado 12 Anos atrás.

RE: Portlet redirection Liferay pages

New Member Postagens: 24 Data de Entrada: 07/01/12 Postagens Recentes
Thanks for the input Ravi.
I actually figured out that there are soooo many ways to handle navigation in Liferay, and even more with JSF ..
thumbnail
Nghia Nguyen, modificado 9 Anos atrás.

RE: Portlet redirection Liferay pages

New Member Mensagem: 1 Data de Entrada: 20/10/12 Postagens Recentes
public void chuyenTrang(String url) {

try {
Map<String, Object> reqestMap = FacesContext.getCurrentInstance().getExternalContext().getRequestMap();
ThemeDisplay themeDisplay = (ThemeDisplay) reqestMap.get("THEME_DISPLAY");
FacesContext.getCurrentInstance().getExternalContext().redirect(themeDisplay.getPortalURL() + url);
}
catch (IOException e) {
e.printStackTrace();
}
}