[ 
https://issues.apache.org/jira/browse/WICKET-4321?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14170701#comment-14170701
 ] 

Martin Grigorov commented on WICKET-4321:
-----------------------------------------

https://github.com/martin-g/component-rendering-default is a demo app showing 
how to achieve the requirement from the mail discussion at users@.

> 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.4.19, 1.5.3, 6.0.0-beta1
>            Reporter: Carl-Eric Menzel
>         Attachments: 
> master-allow-behavior-onexception-to-throw-resetresponse-ex.patch, 
> wicket-1.4.x-allow-behavior-onexception-to-throw-resetresponse-ex.patch, 
> wicket-1.5.x-allow-behavior-onexception-to-throw-resetresponse-ex.patch
>
>
> 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 was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to