Author: mgrigorov
Date: Sat Jul 24 17:52:23 2010
New Revision: 978915

URL: http://svn.apache.org/viewvc?rev=978915&view=rev
Log:
Fix for the new onInitialize code.
MarkupContainer initialize() was creating loops in loops in loops because the 
entry point (initialize method) also created a visitior and calls then the 
entry point (initialize) again on those children (including children of the 
children). This does go wrong (or slow) in an exponential way.

port r964773 from 1.4.x


Modified:
    wicket/trunk/wicket/src/main/java/org/apache/wicket/Component.java
    wicket/trunk/wicket/src/main/java/org/apache/wicket/MarkupContainer.java

Modified: wicket/trunk/wicket/src/main/java/org/apache/wicket/Component.java
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/Component.java?rev=978915&r1=978914&r2=978915&view=diff
==============================================================================
--- wicket/trunk/wicket/src/main/java/org/apache/wicket/Component.java 
(original)
+++ wicket/trunk/wicket/src/main/java/org/apache/wicket/Component.java Sat Jul 
24 17:52:23 2010
@@ -965,6 +965,14 @@ public abstract class Component implemen
         */
        void initialize()
        {
+               doInitialize();
+       }
+
+       /**
+        * Used to call {...@link #onInitialize()}
+        */
+       final void doInitialize()
+       {
                if (!getFlag(FLAG_INITIALIZED))
                {
                        setFlag(FLAG_INITIALIZED, true);

Modified: 
wicket/trunk/wicket/src/main/java/org/apache/wicket/MarkupContainer.java
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/MarkupContainer.java?rev=978915&r1=978914&r2=978915&view=diff
==============================================================================
--- wicket/trunk/wicket/src/main/java/org/apache/wicket/MarkupContainer.java 
(original)
+++ wicket/trunk/wicket/src/main/java/org/apache/wicket/MarkupContainer.java 
Sat Jul 24 17:52:23 2010
@@ -965,8 +965,8 @@ public abstract class MarkupContainer ex
                final IDebugSettings debugSettings = 
Application.get().getDebugSettings();
                if (debugSettings.isLinePreciseReportingOnAddComponentEnabled())
                {
-                       child.setMetaData(ADDED_AT_KEY, 
ComponentStrings.toString(child, new MarkupException(
-                               "added")));
+                       child.setMetaData(ADDED_AT_KEY,
+                               ComponentStrings.toString(child, new 
MarkupException("added")));
                }
 
                final Page page = findPage();
@@ -986,15 +986,21 @@ public abstract class MarkupContainer ex
                }
        }
 
+       /**
+        * Overrides {...@link Component#initialize()} to call {...@link 
Component#doInitialize()} for itself
+        * and for all its children.
+        * 
+        * @see org.apache.wicket.Component#doInitialize()
+        */
        @Override
        final void initialize()
        {
-               super.initialize();
+               super.doInitialize();
                visitChildren(new IVisitor<Component, Void>()
                {
                        public void component(final Component component, final 
IVisit<Void> visit)
                        {
-                               component.initialize();
+                               component.doInitialize();
                        }
                });
        }


Reply via email to