Foren

Servlet to JSF page forward using RequestDispatcher is not working

ramathulasi kudumula, geändert vor 8 Jahren.

Servlet to JSF page forward using RequestDispatcher is not working

Junior Member Beiträge: 51 Beitrittsdatum: 06.10.11 Neueste Beiträge
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, geändert vor 8 Jahren.

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

Liferay Legend Beiträge: 2655 Beitrittsdatum: 27.07.05 Neueste Beiträge
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