dev@javaserverfaces.java.net

Abort further processing of a Faces Request?

From: Lincoln Baxter, III <lincolnbaxter_at_gmail.com>
Date: Sun, 3 Jan 2010 15:57:43 -0500

I'm trying to do a servlet forward in a PhaseListener, via
ExternalContext.dispatch(), before RESTORE_VIEW phase.

What happens, though, is that the lifecycle continues in the current
thread, even though the request has been dispatched. It seems like
dispatch() should do some kind of internal abort to tell Faces to stop
processing. Or... faces should check to see if the request has been
dispatched immediately before attempting the next phase.

Assuming that there is no viewId specified, The result of this is an
Explosion when faces attempts to create a UIViewRoot that doesn't
exist, when instead, I feel the request should already have been
aborted and no view should be created, even if there were to be a
viewId defined.

The forwarded thread completes successfully and the new page displays.

Is this a bug, a spec enhancement, or user error?

Caused by: java.lang.NullPointerException
        at javax.faces.component.UIViewRoot.setLocale(UIViewRoot.java:1470)
        at com.sun.faces.application.view.ViewHandlingStrategy.createView(ViewHandlingStrategy.java:203)
        at com.sun.faces.application.view.FaceletViewHandlingStrategy.createView(FaceletViewHandlingStrategy.java:636)
        at com.sun.faces.application.view.MultiViewHandler.createView(MultiViewHandler.java:161)
        at com.ocpsoft.pretty.application.PrettyViewHandler.createView(PrettyViewHandler.java:52)
        at com.sun.faces.application.view.ViewMetadataImpl.createMetadataView(ViewMetadataImpl.java:101)
        at com.sun.faces.lifecycle.RestoreViewPhase.execute(RestoreViewPhase.java:239)
        at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
        at com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:110)
        at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
        at javax.faces.webapp.FacesServlet.service(FacesServlet.java:310)
        ... 86 more


Thanks,
-- 
Lincoln Baxter, III
http://ocpsoft.com
http://scrumshark.com
"Keep it Simple"