WICKET-6014 improvement for borders with enclosures inside their body
Project: http://git-wip-us.apache.org/repos/asf/wicket/repo Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/297c4e51 Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/297c4e51 Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/297c4e51 Branch: refs/heads/lambdas Commit: 297c4e51a925ef08c3ff903e4db26d2f910fe084 Parents: e704581 Author: Andrea Del Bene <[email protected]> Authored: Sat Oct 31 19:46:44 2015 +0100 Committer: Andrea Del Bene <[email protected]> Committed: Sat Oct 31 20:01:19 2015 +0100 ---------------------------------------------------------------------- .../wicket/markup/html/internal/Enclosure.java | 7 +--- .../markup/html/border/BorderWithEnclosure.html | 14 +++++++ .../markup/html/border/BorderWithEnclosure.java | 42 ++++++++++++++++++++ .../html/border/BorderWithEnclosurePage.html | 14 +++++++ .../html/border/BorderWithEnclosurePage.java | 38 ++++++++++++++++++ .../markup/html/border/ComponentBorderTest.java | 6 +++ 6 files changed, 116 insertions(+), 5 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/wicket/blob/297c4e51/wicket-core/src/main/java/org/apache/wicket/markup/html/internal/Enclosure.java ---------------------------------------------------------------------- diff --git a/wicket-core/src/main/java/org/apache/wicket/markup/html/internal/Enclosure.java b/wicket-core/src/main/java/org/apache/wicket/markup/html/internal/Enclosure.java index 882a3ba..e68f4e0 100644 --- a/wicket-core/src/main/java/org/apache/wicket/markup/html/internal/Enclosure.java +++ b/wicket-core/src/main/java/org/apache/wicket/markup/html/internal/Enclosure.java @@ -193,6 +193,7 @@ public class Enclosure extends WebMarkupContainer implements IComponentResolver // necessary when queued and lives with the page instead of just during render childComponent = null; } + /** * Get the real parent container * @@ -201,11 +202,7 @@ public class Enclosure extends WebMarkupContainer implements IComponentResolver protected MarkupContainer getEnclosureParent() { MarkupContainer parent = getParent(); - while ((parent != null) && parent.isAuto()) - { - parent = parent.getParent(); - } - + if (parent == null) { throw new WicketRuntimeException( http://git-wip-us.apache.org/repos/asf/wicket/blob/297c4e51/wicket-core/src/test/java/org/apache/wicket/markup/html/border/BorderWithEnclosure.html ---------------------------------------------------------------------- diff --git a/wicket-core/src/test/java/org/apache/wicket/markup/html/border/BorderWithEnclosure.html b/wicket-core/src/test/java/org/apache/wicket/markup/html/border/BorderWithEnclosure.html new file mode 100644 index 0000000..e9fa749 --- /dev/null +++ b/wicket-core/src/test/java/org/apache/wicket/markup/html/border/BorderWithEnclosure.html @@ -0,0 +1,14 @@ +<!DOCTYPE html> +<html> +<head> +<meta charset="UTF-8"> +<title>Insert title here</title> +</head> +<body> +<wicket:border> + <div wicket:id="bodyContainer"> + <wicket:body/> + </div> +</wicket:border> +</body> +</html> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/wicket/blob/297c4e51/wicket-core/src/test/java/org/apache/wicket/markup/html/border/BorderWithEnclosure.java ---------------------------------------------------------------------- diff --git a/wicket-core/src/test/java/org/apache/wicket/markup/html/border/BorderWithEnclosure.java b/wicket-core/src/test/java/org/apache/wicket/markup/html/border/BorderWithEnclosure.java new file mode 100644 index 0000000..f418640 --- /dev/null +++ b/wicket-core/src/test/java/org/apache/wicket/markup/html/border/BorderWithEnclosure.java @@ -0,0 +1,42 @@ +/* + * 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.border; + +import org.apache.wicket.markup.html.WebMarkupContainer; + +public class BorderWithEnclosure extends Border +{ + + /** + * + */ + private static final long serialVersionUID = 1L; + + public BorderWithEnclosure(String id) + { + super(id); + + } + + @Override + protected void onInitialize() + { + super.onInitialize(); + addToBorder(new WebMarkupContainer("bodyContainer")); + } + +} http://git-wip-us.apache.org/repos/asf/wicket/blob/297c4e51/wicket-core/src/test/java/org/apache/wicket/markup/html/border/BorderWithEnclosurePage.html ---------------------------------------------------------------------- diff --git a/wicket-core/src/test/java/org/apache/wicket/markup/html/border/BorderWithEnclosurePage.html b/wicket-core/src/test/java/org/apache/wicket/markup/html/border/BorderWithEnclosurePage.html new file mode 100644 index 0000000..4db5d8a --- /dev/null +++ b/wicket-core/src/test/java/org/apache/wicket/markup/html/border/BorderWithEnclosurePage.html @@ -0,0 +1,14 @@ +<!DOCTYPE html> +<html> +<head> +<meta charset="UTF-8"> +<title>Insert title here</title> +</head> +<body> + <div wicket:id="border"> + <wicket:enclosure> + <span wicket:id="label"></span> + </wicket:enclosure> + </div> +</body> +</html> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/wicket/blob/297c4e51/wicket-core/src/test/java/org/apache/wicket/markup/html/border/BorderWithEnclosurePage.java ---------------------------------------------------------------------- diff --git a/wicket-core/src/test/java/org/apache/wicket/markup/html/border/BorderWithEnclosurePage.java b/wicket-core/src/test/java/org/apache/wicket/markup/html/border/BorderWithEnclosurePage.java new file mode 100644 index 0000000..cd8ee27 --- /dev/null +++ b/wicket-core/src/test/java/org/apache/wicket/markup/html/border/BorderWithEnclosurePage.java @@ -0,0 +1,38 @@ +/* + * 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.border; + +import org.apache.wicket.markup.html.WebPage; +import org.apache.wicket.markup.html.basic.Label; + +public class BorderWithEnclosurePage extends WebPage +{ + + /** + * + */ + private static final long serialVersionUID = 1L; + + + public BorderWithEnclosurePage() + { + BorderWithEnclosure border = new BorderWithEnclosure("border"); + border.add(new Label("label")); + + add(border); + } +} http://git-wip-us.apache.org/repos/asf/wicket/blob/297c4e51/wicket-core/src/test/java/org/apache/wicket/markup/html/border/ComponentBorderTest.java ---------------------------------------------------------------------- diff --git a/wicket-core/src/test/java/org/apache/wicket/markup/html/border/ComponentBorderTest.java b/wicket-core/src/test/java/org/apache/wicket/markup/html/border/ComponentBorderTest.java index c2a6e68..fb70117 100644 --- a/wicket-core/src/test/java/org/apache/wicket/markup/html/border/ComponentBorderTest.java +++ b/wicket-core/src/test/java/org/apache/wicket/markup/html/border/ComponentBorderTest.java @@ -112,4 +112,10 @@ public class ComponentBorderTest extends WicketTestCase assertEquals(TEST_TEXT, model.getObject()); } + + @Test + public void borderWithEnclosurePage() throws Exception + { + tester.startPage(BorderWithEnclosurePage.class); + } }
