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]