Fórum

Servlet to JSF page forward using RequestDispatcher is not working

ramathulasi kudumula, modificado 8 Anos atrás.

Servlet to JSF page forward using RequestDispatcher is not working

Junior Member Postagens: 51 Data de Entrada: 06/10/11 Postagens Recentes
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, modificado 8 Anos atrás.

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

Liferay Legend Postagens: 2655 Data de Entrada: 27/07/05 Postagens Recentes
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