My ExceptionHandlerInterceptor works like
this:
When an exception is caught the interceptor sets
the Exception into the ActionContext and tries to create an instance of the
"error" result and execute it (some refactoring of ActionInvocation would have
made this easier). If it cannot do this (ie no "error" result defined for
the action or globally), or another exception is thrown while executing the
result then the exception is re-thrown to the container.
I define my error handling result to "chain" to an error handling
Action.
<!-- per action or global
-->
<result name="error" type="chain"> <param name="actionName">flightError</param> </result> This way the original Action is still on the stack and can be
examined by the error page to give a full error report.
This functionality must go in an interceptor (or the ServletDispatcher) so
that it can surround BOTH the Action.execute() and the Result.execute()
calls. It is adding application specific behaviour which, as previously
discussed, should not go in XWork because in many applications there is another
layer above XWork that would be better suited to handling exceptions.
However, in a WW2 environment there is only the ServletDispatcher
above xwork. The Interceptors and Actions *are* the application.
The main advantages of using a "framework integrated" approach over relying
on the servlet container error-page mechanism are:
1 - Can reference actions defined in the configuration (xwork.xml)
2 - Can report on the current application state in error handler (ie Action
still on stack)
John.
|
Title: Message
- [OS-webwork] ActionInvocation result John Patterson
- RE: [OS-webwork] ActionInvocation result Jason Carreira
- Re: [OS-webwork] ActionInvocation result John Patterson
- Re: [OS-webwork] ActionInvocation result Tim Dwelle
- [OS-webwork] ValueStack being unexpectedly rep... Frederick N. Brier
- Re: [OS-webwork] ValueStack being unexpect... Frederick N. Brier
- RE: [OS-webwork] ValueStack being unex... Patrick Lightbody
- RE: [OS-webwork] ActionInvocation result Jason Carreira
- John Patterson