Re: Handling Exceptions in Action constructors

2008-07-10 Thread Jim Kiley
The thing to remember here is that unlike the constructor, prepare() won't run on its own outside of a Struts context. So if you are writing unit tests of your various execute() type methods, be aware that you will need to run prepare() manually within the unit tests (or as part of setUp() or what

Re: Handling Exceptions in Action constructors

2008-07-10 Thread Lyallex
Sheesh, that works like a dream, thanks ... Can't think how I missed that bit in the book. Preparable, marvelous. lyallex On Wed, Jul 9, 2008 at 5:04 PM, Jim Kiley <[EMAIL PROTECTED]> wrote: > I think in this situation I would have SomeAction implement Preparable, and > put someComponent's init

Re: Handling Exceptions in Action constructors

2008-07-09 Thread Jim Kiley
I think in this situation I would have SomeAction implement Preparable, and put someComponent's initialization into the prepare() method, if I could get away with it. I realize that might not be possible in your situation, but not knowing more details it's my first suggestion. jk On Wed, Jul 9,

Re: Handling exceptions in a custom result

2007-08-07 Thread Vinod Singh
To do have a similar behavior I have extended ServletDispatcherResult and overridden doExecute(...)- @Override public void doExecute(String finalLocation, ActionInvocation invocation) throws Exception { try { // some operation } catch (Exception e) { su

Re: Handling exceptions in a custom result

2007-08-07 Thread Juan Damasceno
It doesn´t works, the Result is executed after the Interceptors On 8/7/07, Thorsten Schäfer <[EMAIL PROTECTED]> wrote: > > > I need to do something like: > > > > public void execute(ActionInvocation invocation) throws > > Exception { > > try { > >// Some operations > >

RE: Handling exceptions in a custom result

2007-08-07 Thread Thorsten Schäfer
> I need to do something like: > > public void execute(ActionInvocation invocation) throws > Exception { > try { >// Some operations > } catch (Exception e) { >//Send user to a error page > } > } > > Any idea? You could write an intercepto

Re: Handling exceptions in a custom result

2007-08-07 Thread Juan Damasceno
Thanks for reply Vinod, but my class is a Result not a action. public class CustomResult implements Result { public void execute(ActionInvocation invocation) throws Exception { try { // Some operations } catch (Exception e) { //Send user to a error page

Re: Handling exceptions in a custom result

2007-08-07 Thread Vinod Singh
Do something like below- path_to_error.jsp public void execute(ActionInvocation invocation) throws Exception { try { // Some operations } catch (Exception e) { //Send user to a error page return "error"; } } Vinod

Re: Handling Exceptions

2006-03-13 Thread Frank W. Zammetti
Here you go: http://struts.apache.org//struts-doc-1.2.7/userGuide/building_controller.html#exception_handler As you describe, I think you'll very much like the global exception handling mechanism. Frank bib_lucene bib wrote: Hi All In my struts based web application how do I handle ex