views:

27

answers:

1

Hello, I try to navigate to another page with redirect by assigning a navigation-rule. The webpage I try to redirect to works just fine when it is directly called.

When I set the edirection to a jsp page which simply includes a <jsp:forward page="faces/another.xhtml" /> message in it, I get this following nullpointerexception and redirection fails:

java.lang.NullPointerException
    at org.icefaces.util.EnvUtils.isICEfacesView(EnvUtils.java:69)
    at org.icefaces.event.BridgeSetup.processEvent(BridgeSetup.java:66)
    at javax.faces.event.SystemEvent.processListener(SystemEvent.java:102)
    at com.sun.faces.application.ApplicationImpl.processListeners(ApplicationImpl.java:1993)
    at com.sun.faces.application.ApplicationImpl.invokeListenersFor(ApplicationImpl.java:1969)
    at com.sun.faces.application.ApplicationImpl.publishEvent(ApplicationImpl.java:299)
    at com.sun.faces.application.ApplicationImpl.publishEvent(ApplicationImpl.java:243)
    at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:114)
    at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
    at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:313)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:849)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:454)
    at java.lang.Thread.run(Unknown Source)
03.Eki.2010 02:07:58 org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet Faces Servlet threw exception
java.lang.NullPointerException
    at javax.faces.component.UIViewRoot.getViewMap(UIViewRoot.java:1523)
    at javax.faces.component.UIViewRoot.getViewMap(UIViewRoot.java:1487)
    at org.icefaces.util.EnvUtils.isICEfacesView(EnvUtils.java:70)
    at org.icefaces.context.DOMPartialViewContext.getPartialResponseWriter(DOMPartialViewContext.java:97)
    at org.icefaces.context.DOMPartialViewContext.getPartialResponseWriter(DOMPartialViewContext.java:95)
    at com.sun.faces.context.AjaxExceptionHandlerImpl.handlePartialResponseError(AjaxExceptionHandlerImpl.java:190)
    at com.sun.faces.context.AjaxExceptionHandlerImpl.handle(AjaxExceptionHandlerImpl.java:119)
    at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:119)
    at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:313)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:849)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:454)
    at java.lang.Thread.run(Unknown Source)

Then I set the navigation-rule directly to /faces/another.xhtml. the redirection is successful, but I get the following warning message:

WARNING: JSF1015: Request path '/faces/another.xhtml' begins with one or more
occurrences of the FacesServlet prefix path mapping '/faces'.

What do you think is the proper way of setting up the navigation? Thank you very much.

+1  A: 

Apparently you're already in JSF context. Remove the /faces prefix from the URL.

<jsp:forward page="another.xhtml" />

Note that you aren't redirecting here, but just forwarding the request to a different source. A redirect basically instructs the client to fire a brand new HTTP request to the server whose URL is then been reflected in browser address bar. A redirect is normally to be done by ExternalContext#redirect() in bean's action method (which is under the covers calling HttpServletResponse#sendRedirect() and then FacesContext#responseComplete()), or by adding a <redirect/> entry to the <navigation-case> in faces-config.xml.

BalusC
thank you for your answer. I also had some confusion about the url not showing in the address bar. now I am clear.
artsince
You're welcome.
BalusC