Thanks for the reply.

I think I will not use onRuntimeException to control my 'business
exceptions' even if it works now. If Wicket doesn't count on such thing, I
have no guarantee that it won't break in the future. 

I'm not sure it will not break in the future.

What I'm afraid 
of changes in the Wicket code in future versions that could break my 


igor.vaynberg wrote:
> 
> good. there are some internals that do not count on a runtime
> exception being thrown because of user code...for example throwing it
> out of something like validator will abort entire form processing, and
> might leave that particular form component in an inconsistent state.
> but throwing it out of onclick/onsubmit handlers shouldnt pose much
> problem as most wicket processing has already happened.
> 
> -igor
> 
> On Feb 18, 2008 8:40 AM, Cristiano Kliemann <[EMAIL PROTECTED]> wrote:
>>
>> Igor,
>>
>> It seems to work with Link.onClick also.
>>
>>
>>
>> Cristiano Kliemann wrote:
>> >
>> > Yes, it works, at least when the exception is thrown in
>> Button.onSubmit. I
>> > haven't tried with Link.onClick.
>> >
>> >
>> > igor.vaynberg wrote:
>> >>
>> >> have you tried it and does it work?
>> >>
>> >> -igor
>> >>
>> >>
>> >> On Feb 15, 2008 1:17 PM, Cristiano Kliemann <[EMAIL PROTECTED]>
>> wrote:
>> >>>
>> >>> Hi!
>> >>>
>> >>> I have some business runtime exceptions that I want to be
>> automatically
>> >>> catched and its message rendered in the same page that threw it
>> instead
>> >>> of
>> >>> redirecting to an error page.
>> >>>
>> >>> Is there a safe way to do that?
>> >>>
>> >>> These 'business exceptions' are usually thrown in some specific
>> methods
>> >>> like
>> >>> onSubmit and onClick. Extending the specific components is not an
>> option
>> >>> for
>> >>> me.
>> >>>
>> >>> I did something I think it dangerous. Something like:
>> >>>
>> >>> public Page onRuntimeException(Page page, RuntimeException e) {
>> >>>
>> >>>     Throwable current = e;
>> >>>     while (current != null && !(current instanceof
>> MyBusinessException))
>> >>> {
>> >>>         current = current.getCause();
>> >>>     }
>> >>>     if (current != null) {
>> >>>         // MyBusinessException detected
>> >>>         page.error("Error: " + current.getMessage());
>> >>>         return page;
>> >>>     } else {
>> >>>         return super.onRuntimeException(page, e);
>> >>>     }
>> >>> }
>> >>>
>> >>> When as exception is thrown, all the execution flow breaks, making
>> some
>> >>> things not happen. The question is: is the above code safe assuming
>> that
>> >>> MyException could be thrown only by methods like onSubmit and
>> onClick?
>> >>> --
>> >>> View this message in context:
>> >>>
>> http://www.nabble.com/Exception-redirecting-to-source-page-tp15510198p15510198.html
>> >>> Sent from the Wicket - User mailing list archive at Nabble.com.
>> >>>
>> >>>
>> >>> ---------------------------------------------------------------------
>> >>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>> >>> For additional commands, e-mail: [EMAIL PROTECTED]
>> >>>
>> >>>
>> >>
>> >> ---------------------------------------------------------------------
>> >> To unsubscribe, e-mail: [EMAIL PROTECTED]
>> >> For additional commands, e-mail: [EMAIL PROTECTED]
>> >>
>> >>
>> >>
>> >
>> >
>>
>> --
>> View this message in context:
>> http://www.nabble.com/Exception-redirecting-to-source-page-tp15510198p15547028.html
>>
>> Sent from the Wicket - User mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>> For additional commands, e-mail: [EMAIL PROTECTED]
>>
>>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Exception-redirecting-to-source-page-tp15510198p15560807.html
Sent from the Wicket - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to