wicket-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michal Kára <lemm...@ucw.cz>
Subject Re-rendering page on errors during onBeforeRender()
Date Tue, 19 May 2015 12:53:37 GMT
I got page with structure like:

- Page
  +- ListView -- items
  \ - Footer panel


Now the scenario (heavily simplified):

One of the items in ListView throws soft exception 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 exception using aspect, replace view in the structure with
the 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(). What happens is that 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 page. 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

Thank you,
Michal.



--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Re-rendering-page-on-errors-during-onBeforeRender-tp4670835.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Mime
View raw message