Fórumok
Portlet redirection Liferay pages
Olivier ROMAND, módosítva 12 év-val korábban
Portlet redirection Liferay pages
New Member Bejegyzések: 24 Csatlakozás dátuma: 2012.01.07. Legújabb bejegyzések
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.
Is it the good way to go ?
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 ?
Ravi Kumar Gupta, módosítva 12 év-val korábban
RE: Portlet redirection Liferay pages
Liferay Legend Bejegyzések: 1302 Csatlakozás dátuma: 2009.06.24. Legújabb bejegyzések
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
To call a portlet on a different page.. see this post http://www.liferay.com/community/forums/-/message_boards/message/10158348
Olivier ROMAND, módosítva 12 év-val korábban
RE: Portlet redirection Liferay pages
New Member Bejegyzések: 24 Csatlakozás dátuma: 2012.01.07. Legújabb bejegyzések
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.
Any hints ?
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 ?
Olivier ROMAND, módosítva 12 év-val korábban
RE: Portlet redirection Liferay pages
New Member Bejegyzések: 24 Csatlakozás dátuma: 2012.01.07. Legújabb bejegyzések
Just found out that this would work.
It somehow sounds like hijacking the whole process .. doesn't it ?
Ravi, what about the same in doView ?
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 ?
Ravi Kumar Gupta, módosítva 12 év-val korábban
RE: Portlet redirection Liferay pages
Liferay Legend Bejegyzések: 1302 Csatlakozás dátuma: 2009.06.24. Legújabb bejegyzések
Hi,
What you did is right. For more can you check this page please http://www.liferay.com/community/forums/-/message_boards/message/493491
What you did is right. For more can you check this page please http://www.liferay.com/community/forums/-/message_boards/message/493491
Olivier ROMAND, módosítva 12 év-val korábban
RE: Portlet redirection Liferay pages
New Member Bejegyzések: 24 Csatlakozás dátuma: 2012.01.07. Legújabb bejegyzések
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 ..
I actually figured out that there are soooo many ways to handle navigation in Liferay, and even more with JSF ..
Nghia Nguyen, módosítva 9 év-val korábban
RE: Portlet redirection Liferay pages
New Member Bejegyzés: 1 Csatlakozás dátuma: 2012.10.20. Legújabb bejegyzések
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();
}
}
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();
}
}