Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Struts
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Jeanne Boyarsky
Ron McLeod
Paul Clapham
Liutauras Vilda
Sheriffs:
paul wheaton
Rob Spoor
Devaka Cooray
Saloon Keepers:
Stephan van Hulst
Tim Holloway
Carey Brown
Frits Walraven
Tim Moores
Bartenders:
Mikalai Zaikin
Forum:
Struts
Get the exception object into Interceptor
Astork rc
Greenhorn
Posts: 1
posted 13 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Hi,
I would like know how to create an interceptor to handle exceptions generated during the processing of an action
package br.interceptors; import org.apache.struts2.StrutsStatics; import com.opensymphony.xwork2.ActionInvocation; import com.opensymphony.xwork2.ValidationAware; import com.opensymphony.xwork2.interceptor.AbstractInterceptor; import com.opensymphony.xwork2.interceptor.PreResultListener; @SuppressWarnings("serial") public class ExceptionPadraoInterceptors extends AbstractInterceptor implements StrutsStatics { public String intercept(ActionInvocation invocation) throws Exception { invocation.addPreResultListener(new PreResultListener() { public void beforeResult(ActionInvocation action, String resultCode) { // >>>> Get the exception object here } }); return invocation.invoke(); } private void addActionError(ActionInvocation invocation, String message) { Object action = invocation.getAction(); if (action instanceof ValidationAware) { ((ValidationAware) action).addActionError(message); } } private void addActionMessage(ActionInvocation invocation, String message) { Object action = invocation.getAction(); if (action instanceof ValidationAware) { ((ValidationAware) action).addActionMessage(message); } } }
How do I do this?
Tks
David Newton
Author
Posts: 12617
I like...
posted 13 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Maybe look at the code for the exception interceptor.
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
Logout is not properly working in struts2 please help me
Need help for refreshing the page
Bean values are null
Struts 2: Custom display of error messages
More...