[
https://issues.apache.org/jira/browse/WICKET-4012?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13095580#comment-13095580
]
Martin Grigorov commented on WICKET-4012:
-----------------------------------------
The solution for the problem with onAfterRender() is to remove
org.apache.wicket.MarkupContainer.onAfterRenderChildren().
There is no need of this method. Component.afterRender() is called right after
internalRender() in Component.render().
Parent's afterRender() comes after its children afterRender() so there is no
reason to call it again.
But now there are 4 tests for Enclosures which fail...
> 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: 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