kris-32 wrote:
>
> Pls help me to setup the Exception handling...
> 1.how to catch the exception occuring in ActionBean method, using our
> custom
> exception handle method? not sure to integrate this both?
Once you have created your own exception handler, you can do pretty-much
whatever you like with whatever exception you are looking for. For example:
public class MyExceptionHandler implements ExceptionHandler {
private Configuration configuration;
public void init(Configuration configuration) throws Exception {
this.configuration = configuration;
}
public void handle(Throwable throwable, HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
BootstrapPropertyResolver bootstrap =
getConfiguration().getBootstrapPropertyResolver();
try {
StripesRequestWrapper wrapper = new StripesRequestWrapper(request) {
@Override
protected void constructMultipartWrapper(HttpServletRequest
request) throws StripesServletException {
Locale locale =
StripesFilter.getConfiguration().getLocalePicker().pickLocale(request);
setLocale(locale);
}
};
ActionBeanContext context =
StripesFilter.getConfiguration().getActionBeanContextFactory().getContextInstance(wrapper,
response);
ForwardResolution next = new ForwardResolution("/Error.action");
if (throwable instanceof CustomExceptionType1) {
next = new ForwardResolution("/Custom1.action");
next.setParameter("test", 1234);
} else if (throwable instanceof CustomExceptionType2) {
} else if (throwable instanceof CustomExceptionType3) {
} else {
}
next.execute(wrapper, response);
} catch (Exception e) {
// anything else
}
}
This is just a simple example, but shows you some of what's possible.
Whenever an exception is thrown anywhere inside the Stripes Filter, you can
catch it--along with the context, you filter configuration (which means just
about everything else), the request, the response... the kitchen sink.
To answer your question more specifically: just write your own Exception
classes. Then, whenever you throw one of those exceptions--from just about
anywhere, including ActionBeans, they will be intercepted properly.
--
View this message in context:
http://www.nabble.com/Exception-Handling-Stripes-tp15498292p16342905.html
Sent from the stripes-users mailing list archive at Nabble.com.
-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
Stripes-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/stripes-users