[
https://issues.apache.org/jira/browse/WICKET-4012?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Martin Grigorov updated WICKET-4012:
------------------------------------
Attachment: WICKET-4012-afterRender.patch
Attaching a patch for onAfterRender() problem.
Now instead of calling onAfterRender() on the children components which
normally already had executed this method we just set RENDERING_FLAG to false.
This is needed because of two reasons:
1) this flag is being set even for invisible components (see
org.apache.wicket.Component.internalRender(), line 2320 and the check in 2332)
2) in Ajax request Enclosure needs to update this flag for its child component.
The specifics are not very clear to me.
> Component's onAfterRender() is called so many times as it is depth in the
> component tree + 1
> --------------------------------------------------------------------------------------------
>
> Key: WICKET-4012
> URL: https://issues.apache.org/jira/browse/WICKET-4012
> Project: Wicket
> Issue Type: Bug
> Components: wicket
> Affects Versions: 1.5-RC7
> Reporter: Martin Grigorov
> Fix For: 1.5.1
>
> Attachments: WICKET-4012-afterRender.patch, detachedTwice.patch,
> wicket-4012.tar.gz
>
>
> org.apache.wicket.Component.afterRender() calls
> org.apache.wicket.Component.onAfterRenderChildren() which for
> MarkupContainers calls afterRender() for its children.
> So for code like:
> WebMarkupContainer comp1 = new WebMarkupContainer("c1");
> add(comp1);
>
> WebMarkupContainer comp2 = new WebMarkupContainer("c2");
> comp1.add(comp2);
>
> WebMarkupContainer comp3 = new WebMarkupContainer("c3") {
> @Override
> protected void onAfterRender() {
> super.onAfterRender();
> System.err.println("called");
> }
>
> };
> comp2.add(comp3);
> you'll see "called" printed 4 times in a single request.
> Additionally I think onAfterRenderChildren() should be called before
> onAfterRender() in Component.afterRender(). The flow should be first-in
> last-out: onBeforeRender > onBeforeRenderChildren > onAfterRenderChildren >
> onAfterRender,
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira