Uploaded image for project: 'Wicket'
  1. Wicket
  2. WICKET-4321

Allow Behaviors to issue a response restart on a render exception

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 1.4.19, 1.5.3, 6.0.0-beta1
    • None
    • wicket
    • None

    Description

      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.

      Attachments

        Activity

          People

            Unassigned Unassigned
            cmenzel Carl-Eric Menzel
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: