Allow Behaviors to issue a response restart on a render exception
-----------------------------------------------------------------
Key: WICKET-4321
URL: https://issues.apache.org/jira/browse/WICKET-4321
Project: Wicket
Issue Type: Improvement
Components: wicket
Affects Versions: 1.5.3, 1.4.19, 6.0.0
Reporter: Carl-Eric Menzel
Currently, when an exception occurs during the render phase, it propagates all
the way out to the request cycle. Components can't react at all, behaviors are
only called to allow them to clean up any resources.
This strikes me as a bit inflexible, since that means any exceptions thrown
e.g. by a LoadableDetachableModel or any other lazy loading construct can not
be handled in the page or the component where they occur. It always leaks out
to the RequestCycle (or its listeners). I have a number of models that do
remote calls to load required data. If that doesn't work, I'd like to decide
what to do close to where it happens - in the component.
If an exception happens during rendering, a component probably shouldn't do
much anymore, since who knows what state it's in. But a behavior is isolated
enough that it could decide to show a new page, for example. I propose that the
code calling Behavior#onException catches not just all Throwables, but
ResetResponseException and its subclasses, and rethrows the last one it gets of
those. This way the default behavior is unchanged, all behaviors will be called
to clean up their resources, and if a behavior decides, based on the exception,
to render a new page, it can do that. If more than one wants to do it, the last
one wins.
I will attach patches for all three major branches, including tests that
demonstrate the new behavior and prove that nothing is broken.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira