留言板

Servlet to JSF page forward using RequestDispatcher is not working

ramathulasi kudumula,修改在8 年前。

Servlet to JSF page forward using RequestDispatcher is not working

Junior Member 帖子: 51 加入日期: 11-10-6 最近的帖子
Hi,

I am not able to forward to a jsf page using servlet request dispatcher in liferay 6.2 portal.

Donot know where i have made a mistake.

Attaching the sample code for reference. PFA and suggest on the same.

Appreciate if some one provides me some sample portlet using the same.

Regards
Thulasi
thumbnail
Neil Griffin,修改在8 年前。

RE: Servlet to JSF page forward using RequestDispatcher is not working

Liferay Legend 帖子: 2655 加入日期: 05-7-27 最近的帖子
Hi Ramathulasi,

For portlet projects in general, you should try to avoid introducing a <servlet> into your WEB-INF/web.xml descriptor. Plain Java portlets that extend javax.portlet.GenericPortlet have the ability to redirect with a PortletRequestDispatcher. But JSF Portlets (like the one you attached) should redirect like this:

<p:commandbutton ajax="false" action="#{myBackingBean.submit}" />

public void submit() {
    FacesContext facesContext = FacesContext.getCurrentInstance();
    ExternalContext externalContext = facesContext.getExternalContext();
    externalContext.redirect("/views/nextView.xhtml");
}


Alternatively you can define a navigation-rule in the WEB-INF/faces-config.xml descriptor that has a <redirect/> element. Also, you can specify ?faces-redirect=true with implicit navigation, like this:

<p:commandbutton ajax="false" action="/views/nextView.xhtml?faces-redirect=true" />


Kind Regards,

Neil