You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by sv...@apache.org on 2012/08/03 19:41:03 UTC

[1/2] git commit: removed unnecessary beforeRender() calls on IFeedbacks

Updated Branches:
  refs/heads/master f17b6e491 -> 772122a6d


removed unnecessary beforeRender() calls on IFeedbacks


Project: http://git-wip-us.apache.org/repos/asf/wicket/repo
Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/772122a6
Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/772122a6
Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/772122a6

Branch: refs/heads/master
Commit: 772122a6d74344f7ebf6219064c3a4f91f3d0481
Parents: 5f00e55
Author: svenmeier <sv...@apache.org>
Authored: Fri Aug 3 19:39:40 2012 +0200
Committer: svenmeier <sv...@apache.org>
Committed: Fri Aug 3 19:39:40 2012 +0200

----------------------------------------------------------------------
 .../src/main/java/org/apache/wicket/Component.java |    8 +-
 .../apache/wicket/feedback/FeedbackRenderTest.java |   40 ++++++++
 .../org/apache/wicket/feedback/FeedbacksPage.html  |   27 +++++
 .../org/apache/wicket/feedback/FeedbacksPage.java  |   79 +++++++++++++++
 4 files changed, 152 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/wicket/blob/772122a6/wicket-core/src/main/java/org/apache/wicket/Component.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/Component.java b/wicket-core/src/main/java/org/apache/wicket/Component.java
index 3ed5afa..57d472d 100644
--- a/wicket-core/src/main/java/org/apache/wicket/Component.java
+++ b/wicket-core/src/main/java/org/apache/wicket/Component.java
@@ -969,9 +969,13 @@ public abstract class Component
 					new IVisitor<Component, Void>()
 					{
 						@Override
-						public void component(Component component, IVisit<Void> visit)
+						public void component(Component feedback, IVisit<Void> visit)
 						{
-							component.beforeRender();
+							feedback.beforeRender();
+
+							// don't need to go deeper,
+							// as the feedback will visit its children on its own
+							visit.dontGoDeeper();
 						}
 					});
 			}

http://git-wip-us.apache.org/repos/asf/wicket/blob/772122a6/wicket-core/src/test/java/org/apache/wicket/feedback/FeedbackRenderTest.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/test/java/org/apache/wicket/feedback/FeedbackRenderTest.java b/wicket-core/src/test/java/org/apache/wicket/feedback/FeedbackRenderTest.java
new file mode 100644
index 0000000..91a1e40
--- /dev/null
+++ b/wicket-core/src/test/java/org/apache/wicket/feedback/FeedbackRenderTest.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.wicket.feedback;
+
+import org.apache.wicket.Component;
+import org.apache.wicket.WicketTestCase;
+
+/**
+ * Test calling of {@link Component#beforeRender()} for {@link IFeedback} components.
+ */
+public class FeedbackRenderTest extends WicketTestCase
+{
+
+	/**
+	 * @throws Exception
+	 */
+	public void test() throws Exception
+	{
+		final FeedbacksPage page = new FeedbacksPage();
+
+		tester.startPage(page);
+
+		// non-IFeedback first, then IFeedback from nested to top
+		assertEquals("|id4|id3|id2|id1", page.onBeforeRenderOrder.toString());
+	}
+}

http://git-wip-us.apache.org/repos/asf/wicket/blob/772122a6/wicket-core/src/test/java/org/apache/wicket/feedback/FeedbacksPage.html
----------------------------------------------------------------------
diff --git a/wicket-core/src/test/java/org/apache/wicket/feedback/FeedbacksPage.html b/wicket-core/src/test/java/org/apache/wicket/feedback/FeedbacksPage.html
new file mode 100644
index 0000000..8d9000f
--- /dev/null
+++ b/wicket-core/src/test/java/org/apache/wicket/feedback/FeedbacksPage.html
@@ -0,0 +1,27 @@
+<!--
+    ====================================================================
+    Licensed under the Apache License, Version 2.0 (the "License");
+    you may not use this file except in compliance with the License.
+    You may obtain a copy of the License at
+
+     http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+-->
+<html>
+<body>
+<span wicket:id="id1">
+	<span wicket:id="id2">
+		<span wicket:id="id3">
+		</span>
+	</span>
+</span>	
+
+<span wicket:id="id4">
+</span>
+</body>
+</html>

http://git-wip-us.apache.org/repos/asf/wicket/blob/772122a6/wicket-core/src/test/java/org/apache/wicket/feedback/FeedbacksPage.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/test/java/org/apache/wicket/feedback/FeedbacksPage.java b/wicket-core/src/test/java/org/apache/wicket/feedback/FeedbacksPage.java
new file mode 100644
index 0000000..840495c
--- /dev/null
+++ b/wicket-core/src/test/java/org/apache/wicket/feedback/FeedbacksPage.java
@@ -0,0 +1,79 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.wicket.feedback;
+
+import org.apache.wicket.markup.html.WebMarkupContainer;
+import org.apache.wicket.markup.html.WebPage;
+
+/**
+ */
+public class FeedbacksPage extends WebPage
+{
+
+	private static final long serialVersionUID = 1L;
+
+	public final StringBuilder onBeforeRenderOrder = new StringBuilder();
+
+	/**
+	 */
+	public FeedbacksPage()
+	{
+
+		Impl impl1 = new FeedbackImpl("id1");
+		add(impl1);
+
+		Impl impl2 = new FeedbackImpl("id2");
+		impl1.add(impl2);
+
+		Impl impl3 = new FeedbackImpl("id3");
+		impl2.add(impl3);
+
+		Impl impl4 = new Impl("id4");
+		add(impl4);
+	}
+
+	private class Impl extends WebMarkupContainer
+	{
+
+		private static final long serialVersionUID = 1L;
+
+		private Impl(String id)
+		{
+			super(id);
+		}
+
+		@Override
+		protected void onBeforeRender()
+		{
+			onBeforeRenderOrder.append("|");
+			onBeforeRenderOrder.append(getId());
+
+			super.onBeforeRender();
+		}
+	}
+
+	private class FeedbackImpl extends Impl implements IFeedback
+	{
+
+		private static final long serialVersionUID = 1L;
+
+		private FeedbackImpl(String id)
+		{
+			super(id);
+		}
+	}
+}