You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by ad...@apache.org on 2016/03/18 16:11:04 UTC
wicket git commit: WICKET-6116 Exception 'A child already exists'
when backing to a page with some markups in a Border
Repository: wicket
Updated Branches:
refs/heads/wicket-7.x 65c5df803 -> d697562b7
WICKET-6116 Exception 'A child already exists' when backing to a page with some markups in a Border
Now autocomponents are added to border and not to its body
Project: http://git-wip-us.apache.org/repos/asf/wicket/repo
Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/d697562b
Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/d697562b
Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/d697562b
Branch: refs/heads/wicket-7.x
Commit: d697562b731e5b439fcd435846cb9a6496f75f03
Parents: 65c5df8
Author: Andrea Del Bene <ad...@apache.org>
Authored: Fri Mar 18 16:09:10 2016 +0100
Committer: Andrea Del Bene <ad...@apache.org>
Committed: Fri Mar 18 16:10:22 2016 +0100
----------------------------------------------------------------------
.../wicket/markup/html/border/Border.java | 2 +-
.../autocomponent/AutoComponentsBorder.html | 4 +++
.../autocomponent/AutoComponentsBorder.java | 29 +++++++++++++++++++
.../AutocomponetsGenerationTest.java | 30 ++++++++++++++++----
4 files changed, 59 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/wicket/blob/d697562b/wicket-core/src/main/java/org/apache/wicket/markup/html/border/Border.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/markup/html/border/Border.java b/wicket-core/src/main/java/org/apache/wicket/markup/html/border/Border.java
index 63da8f3..5ef0468 100644
--- a/wicket-core/src/main/java/org/apache/wicket/markup/html/border/Border.java
+++ b/wicket-core/src/main/java/org/apache/wicket/markup/html/border/Border.java
@@ -218,7 +218,7 @@ public abstract class Border extends WebMarkupContainer implements IComponentRes
{
for (Component component : children)
{
- if (component == body)
+ if (component == body || component.isAuto())
{
addToBorder(component);
}
http://git-wip-us.apache.org/repos/asf/wicket/blob/d697562b/wicket-core/src/test/java/org/apache/wicket/markup/html/autocomponent/AutoComponentsBorder.html
----------------------------------------------------------------------
diff --git a/wicket-core/src/test/java/org/apache/wicket/markup/html/autocomponent/AutoComponentsBorder.html b/wicket-core/src/test/java/org/apache/wicket/markup/html/autocomponent/AutoComponentsBorder.html
new file mode 100644
index 0000000..5c3706e
--- /dev/null
+++ b/wicket-core/src/test/java/org/apache/wicket/markup/html/autocomponent/AutoComponentsBorder.html
@@ -0,0 +1,4 @@
+<wicket:border>
+ <img src="img/relative_path_autocomponent.png">
+ <wicket:body/>
+</wicket:border>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/wicket/blob/d697562b/wicket-core/src/test/java/org/apache/wicket/markup/html/autocomponent/AutoComponentsBorder.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/test/java/org/apache/wicket/markup/html/autocomponent/AutoComponentsBorder.java b/wicket-core/src/test/java/org/apache/wicket/markup/html/autocomponent/AutoComponentsBorder.java
new file mode 100644
index 0000000..baafdce
--- /dev/null
+++ b/wicket-core/src/test/java/org/apache/wicket/markup/html/autocomponent/AutoComponentsBorder.java
@@ -0,0 +1,29 @@
+/**
+ * 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.markup.html.autocomponent;
+
+import org.apache.wicket.markup.html.border.Border;
+
+public class AutoComponentsBorder extends Border
+{
+
+ public AutoComponentsBorder(String id)
+ {
+ super(id);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/wicket/blob/d697562b/wicket-core/src/test/java/org/apache/wicket/markup/html/autocomponent/AutocomponetsGenerationTest.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/test/java/org/apache/wicket/markup/html/autocomponent/AutocomponetsGenerationTest.java b/wicket-core/src/test/java/org/apache/wicket/markup/html/autocomponent/AutocomponetsGenerationTest.java
index ba36883..7c0f45d 100644
--- a/wicket-core/src/test/java/org/apache/wicket/markup/html/autocomponent/AutocomponetsGenerationTest.java
+++ b/wicket-core/src/test/java/org/apache/wicket/markup/html/autocomponent/AutocomponetsGenerationTest.java
@@ -16,18 +16,18 @@
*/
package org.apache.wicket.markup.html.autocomponent;
+import org.apache.wicket.core.util.string.ComponentRenderer;
import org.apache.wicket.markup.IMarkupCache;
-import org.apache.wicket.markup.html.internal.HtmlHeaderContainer;
import org.apache.wicket.util.tester.WicketTestCase;
import org.junit.Test;
-/*
- * Test case for https://issues.apache.org/jira/browse/WICKET-5904
- * and for https://issues.apache.org/jira/browse/WICKET-5908
- */
public class AutocomponetsGenerationTest extends WicketTestCase
{
+ /*
+ * Test for https://issues.apache.org/jira/browse/WICKET-5904
+ * and for https://issues.apache.org/jira/browse/WICKET-5908
+ */
@Test
public void autocomponetsNumberDoesntChange()
{
@@ -45,4 +45,24 @@ public class AutocomponetsGenerationTest extends WicketTestCase
//the number of child components must not have been changed
assertEquals(childrenNumber, tester.getLastRenderedPage().size());
}
+
+ /*
+ * Test for https://issues.apache.org/jira/browse/WICKET-6116
+ */
+ @Test
+ public void borderResolvesAutocomponents() throws Exception
+ {
+ AutoComponentsBorder border = new AutoComponentsBorder("id");
+
+ ComponentRenderer.renderComponent(border);
+
+ //we expect to have a body container and an autocomponent for <img> tag
+ assertEquals(2, border.size());
+
+ //let's render the same border again
+ ComponentRenderer.renderComponent(border);
+
+ //the number of child components must not have been changed
+ assertEquals(2, border.size());
+ }
}