Author: jcompagner
Date: Fri Jul 16 11:36:27 2010
New Revision: 964773
URL: http://svn.apache.org/viewvc?rev=964773&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.
Modified:
wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/Component.java
wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/MarkupContainer.java
Modified:
wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/Component.java
URL:
http://svn.apache.org/viewvc/wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/Component.java?rev=964773&r1=964772&r2=964773&view=diff
==============================================================================
---
wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/Component.java
(original)
+++
wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/Component.java
Fri Jul 16 11:36:27 2010
@@ -3944,10 +3944,19 @@ public abstract class Component implemen
}
/**
- * Used to call {...@link #onInitialize()}
+ * Calls {...@link #doInitialize()}, is overridden by {...@link
MarkupContainer} to create an
+ * {...@link IVisitor} to walk over the child hierarchy.
*/
void initialize()
{
+ doInitialize();
+ }
+
+ /**
+ * Used to call {...@link #onInitialize()}
+ */
+ final void doInitialize()
+ {
if (!getFlag(FLAG_INITIALIZED))
{
onInitialize();
Modified:
wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/MarkupContainer.java
URL:
http://svn.apache.org/viewvc/wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/MarkupContainer.java?rev=964773&r1=964772&r2=964773&view=diff
==============================================================================
---
wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/MarkupContainer.java
(original)
+++
wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/MarkupContainer.java
Fri Jul 16 11:36:27 2010
@@ -401,15 +401,21 @@ public abstract class MarkupContainer ex
return getPage().getMarkupType();
}
+ /**
+ * 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>()
{
public Object component(Component component)
{
- component.initialize();
+ component.doInitialize();
return CONTINUE_TRAVERSAL;
}
});