[ 
https://issues.apache.org/jira/browse/WICKET-5911?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Martin Grigorov updated WICKET-5911:
------------------------------------
    Fix Version/s:     (was: 7.0.0)
                   7.0.0-M6

> Re-rendering page after exception in render phase does not call 
> onBeforeRender()
> --------------------------------------------------------------------------------
>
>                 Key: WICKET-5911
>                 URL: https://issues.apache.org/jira/browse/WICKET-5911
>             Project: Wicket
>          Issue Type: Bug
>          Components: wicket
>    Affects Versions: 7.0.0-M6
>            Reporter: Michal Kara
>            Assignee: Sven Meier
>            Priority: Minor
>             Fix For: 6.20.0, 7.0.0-M6
>
>
> (I sent this to the mailing list originaly, Sven Meier replied this is 
> probably a bug and requested creating a JIRA issue for it.)
> I got page with structure like: 
> - Page 
>   +- ListView -- items 
>   \ - Footer panel 
> Now the scenario (heavily simplified): 
> One of the items in ListView gets exception from backend during 
> onInitialize(). Required behavior in this case is to keep user on the page 
> and replace ListView with a panel stating "Sorry, backend outage". 
> So I catch the backend exception using aspect, replace view in the structure 
> with the message panel and throw NonResettingRestartException to restart 
> rendering the page. 
> Page is rendered and seems OK, BUT I realize onBeforeRender() of Footer panel 
> is never called. 
> I debugged it and found the cause: 
> ListView adds items in onPopulate() method which is called from 
> onBeforeRender(). When page starts rendering, its onBeforeRender() is called. 
> Page does: 
> setFlag(FLAG_PREPARED_FOR_RENDER, true); 
> and calls onBeforeRenderChildren(). This calls onBeforeRender() of ListView, 
> causes exception, so that onBeforeRender() of the footer is not called this 
> time. 
> When second rendering is attempted, call flow gets to internalBeforeRender() 
> of the page component. There is check: 
> if ((determineVisibility()) && !getFlag(FLAG_RENDERING) && 
> !getFlag(FLAG_PREPARED_FOR_RENDER)) { 
>   ... 
>   onBeforeRender(); 
>   ... 
> } 
> But since FLAG_PREPARED_FOR_RENDER is set from previous attempt, 
> onBeforeRender() of the page is not called (again) which means 
> onBeforeRender() of the children is not called. 
> I found that if I call 
> markRendering(false); 
> on the page before throwing the NonResettingRestartException, all goes well. 
> But I am quite uneasy about this solution, so I have two questions: 
> 1) Cannot this cause some unforeseen troubles? (Supposing my components are 
> correctly written so that their onBeforeRender() / onConfigure() / 
> onAfterRender() procedures can be safely called multiple times.) 
> 2) Should not Wicket itself reset the FLAG_PREPARED_FOR_RENDER when response 
> restarting exception is caught and processed? 
> I created a Wicket quickstart project demonstrating the bug here: 
> http://lemming.hofyland.cz/restartbug.zip



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to