You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by "Carl-Eric Menzel (Created) (JIRA)" <ji...@apache.org> on 2012/01/02 15:48:31 UTC

[jira] [Created] (WICKET-4321) Allow Behaviors to issue a response restart on a render exception

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

        

[jira] [Updated] (WICKET-4321) Allow Behaviors to issue a response restart on a render exception

Posted by "Carl-Eric Menzel (Updated) (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/WICKET-4321?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Carl-Eric Menzel updated WICKET-4321:
-------------------------------------

    Attachment: wicket-1.5.x-allow-behavior-onexception-to-throw-resetresponse-ex.patch
                wicket-1.4.x-allow-behavior-onexception-to-throw-resetresponse-ex.patch
                master-allow-behavior-onexception-to-throw-resetresponse-ex.patch

A set of patches for master, wicket-1.5.x and wicket-1.4.x, respectively, that changes Component#onException to capture ResetResponseExceptions and rethrow them. Includes tests to prove this.
                
> 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
>            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 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