java.lang.Objectjavax.faces.context.ExceptionHandler
All Implemented Interfaces:
SystemEventListener
Direct Known Subclasses:
PreJsf2ExceptionHandler, ExceptionHandlerWrapper
ExceptionHandler is the
central point for handling unexpected
Exception
s that are thrown during the Faces
lifecycle. The ExceptionHandler
must not be notified of
any Exception
s that occur during application startup or
shutdown.
See the specification prose document for the requirements for the
default implementation. Exception
s may be passed to the
ExceptionHandler
in one of two ways:
by ensuring that Exception
s are not caught, or
are caught and re-thrown.
This approach allows the ExceptionHandler
facility specified in section JSF.6.2 to operate on the
Exception
.
By using the system event facility to publish an ExceptionQueuedEvent that wraps the Exception
.
This approach requires manually publishing the ExceptionQueuedEvent , but allows more information about the
Exception
to be stored in the event. The
following code is an example of how to do this.
//...
} catch (Exception e) {
FacesContext ctx = FacesContext.getCurrentInstance();
ExceptionQueuedEventContext eventContext = new ExceptionQueuedEventContext(ctx, e);
eventContext.getAttributes().put("key", "value");
ctx.getApplication().publishEvent(ExceptionQueuedEvent.class, eventContext);
}
Because the Exception
must not be re-thrown
when using this approach, lifecycle processing may continue
as normal, allowing more Exception
s to be
published if necessary.
With either approach, any ExceptionQueuedEvent
instances
that are published in this way are accessible to the #handle
method, which is called at the end of each lifecycle phase, as
specified in section JSF.6.2.
Instances of this class are request scoped and are created by virtue of FacesContextFactory#getFacesContext calling ExceptionHandlerFactory#getExceptionHandler .
2.0
- Method from javax.faces.context.ExceptionHandler Summary: |
---|
getHandledExceptionQueuedEvent, getHandledExceptionQueuedEvents, getRootCause, getUnhandledExceptionQueuedEvents, handle, isListenerForSource, processEvent |
Methods from java.lang.Object: |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method from javax.faces.context.ExceptionHandler Detail: |
---|
Return the first
|
The default implementation must
return an |
Unwrap the argument |
Return an |
Take action to handle the
|
|
|