Author: jdonnerstag
Date: Wed Apr 2 03:10:50 2008
New Revision: 643829
URL: http://svn.apache.org/viewvc?rev=643829&view=rev
Log:
fixed wicket-1338: enclosures on nested components within wicket:extends
Added:
wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/internal/EnclosurePageExpectedResult_4-1.html
wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/internal/EnclosurePageExpectedResult_4.html
wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/internal/EnclosurePageExpectedResult_5-1.html
wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/internal/EnclosurePageExpectedResult_5.html
wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/internal/EnclosurePage_4.html
wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/internal/EnclosurePage_4.java
wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/internal/EnclosurePage_5.html
wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/internal/EnclosurePage_5.java
wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/internal/EnclosurePage_5_Base.html
wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/internal/EnclosurePage_5_Base.java
Modified:
wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/internal/Enclosure.java
wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/internal/EnclosureTest.java
Modified:
wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/internal/Enclosure.java
URL:
http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/internal/Enclosure.java?rev=643829&r1=643828&r2=643829&view=diff
==============================================================================
---
wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/internal/Enclosure.java
(original)
+++
wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/internal/Enclosure.java
Wed Apr 2 03:10:50 2008
@@ -116,28 +116,7 @@
{
if (childComponent == null)
{
- MarkupContainer parent = getParent();
- while (parent != null)
- {
- if (parent.isTransparentResolver())
- {
- parent = parent.getParent();
- }
- else if (parent instanceof BorderBodyContainer)
- {
- parent =
((BorderBodyContainer)parent).findParent(Border.class);
- }
- else
- {
- break;
- }
- }
-
- if (parent == null)
- {
- throw new WicketRuntimeException(
- "Unable to find parent component which
is not a transparent resolver");
- }
+ MarkupContainer parent = getEnclosureParent();
if (childId == null)
{
@@ -158,6 +137,38 @@
}
/**
+ * Get the real parent container
+ *
+ * @return
+ */
+ private MarkupContainer getEnclosureParent()
+ {
+ MarkupContainer parent = getParent();
+ while (parent != null)
+ {
+ if (parent.isTransparentResolver())
+ {
+ parent = parent.getParent();
+ }
+ else if (parent instanceof BorderBodyContainer)
+ {
+ parent =
((BorderBodyContainer)parent).findParent(Border.class);
+ }
+ else
+ {
+ break;
+ }
+ }
+
+ if (parent == null)
+ {
+ throw new WicketRuntimeException(
+ "Unable to find parent component which is not a
transparent resolver");
+ }
+ return parent;
+ }
+
+ /**
*
* @see
org.apache.wicket.MarkupContainer#onComponentTagBody(org.apache.wicket.markup.MarkupStream,
* org.apache.wicket.markup.ComponentTag)
@@ -170,24 +181,22 @@
throw new WicketRuntimeException(
"Programming error: childComponent == enclose
component; endless loop");
}
- else if (controller != null)
- {
- setVisible(controller.determineVisibility());
- // transfer visiblity to direct children
- DirectChildTagIterator it = new
DirectChildTagIterator(markupStream, openTag);
- while (it.hasNext())
- {
- ComponentTag t = (ComponentTag)it.next();
- Component child =
controller.getParent().get(t.getId());
- if (child != null)
- {
- child.setVisibilityAllowed(isVisible());
- }
- }
- it.rewind();
+ setVisible(controller.determineVisibility());
+ // transfer visibility to direct children
+ DirectChildTagIterator it = new
DirectChildTagIterator(markupStream, openTag);
+ MarkupContainer controllerParent = getEnclosureParent();
+ while (it.hasNext())
+ {
+ ComponentTag t = (ComponentTag)it.next();
+ Component child = controllerParent.get(t.getId());
+ if (child != null)
+ {
+ child.setVisibilityAllowed(isVisible());
+ }
}
+ it.rewind();
if (isVisible() == true)
{
@@ -202,7 +211,6 @@
/**
* Iterator that iterates over direct child component tags of the given
component tag
*
- * @author ivaynberg
*/
private static class DirectChildTagIterator extends ReadOnlyIterator
{
@@ -211,6 +219,12 @@
private ComponentTag next = null;
private final int originalIndex;
+ /**
+ * Construct.
+ *
+ * @param markupStream
+ * @param parent
+ */
public DirectChildTagIterator(MarkupStream markupStream,
ComponentTag parent)
{
super();
Added:
wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/internal/EnclosurePageExpectedResult_4-1.html
URL:
http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/internal/EnclosurePageExpectedResult_4-1.html?rev=643829&view=auto
==============================================================================
---
wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/internal/EnclosurePageExpectedResult_4-1.html
(added)
+++
wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/internal/EnclosurePageExpectedResult_4-1.html
Wed Apr 2 03:10:50 2008
@@ -0,0 +1,9 @@
+<html xmlns:wicket>
+<body>
+ <wicket:enclosure child="foo:bar">
+ <div wicket:id="foo">
+ <div wicket:id="bar">bazqux</div>
+ </div>
+ </wicket:enclosure>
+</body>
+</html>
Added:
wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/internal/EnclosurePageExpectedResult_4.html
URL:
http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/internal/EnclosurePageExpectedResult_4.html?rev=643829&view=auto
==============================================================================
---
wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/internal/EnclosurePageExpectedResult_4.html
(added)
+++
wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/internal/EnclosurePageExpectedResult_4.html
Wed Apr 2 03:10:50 2008
@@ -0,0 +1,5 @@
+<html xmlns:wicket>
+<body>
+ <wicket:enclosure child="foo:bar"></wicket:enclosure>
+</body>
+</html>
Added:
wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/internal/EnclosurePageExpectedResult_5-1.html
URL:
http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/internal/EnclosurePageExpectedResult_5-1.html?rev=643829&view=auto
==============================================================================
---
wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/internal/EnclosurePageExpectedResult_5-1.html
(added)
+++
wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/internal/EnclosurePageExpectedResult_5-1.html
Wed Apr 2 03:10:50 2008
@@ -0,0 +1,14 @@
+<html>
+<body>
+This is in the super markup.<br>
+<wicket:child><wicket:extend>
+ <wicket:enclosure child="foo:bar">
+ <div wicket:id="foo">
+ <div wicket:id="bar">bazqux</div>
+ </div>
+ </wicket:enclosure>
+</wicket:extend></wicket:child>
+This is in the super markup.<br>
+</body>
+</html>
+
Added:
wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/internal/EnclosurePageExpectedResult_5.html
URL:
http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/internal/EnclosurePageExpectedResult_5.html?rev=643829&view=auto
==============================================================================
---
wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/internal/EnclosurePageExpectedResult_5.html
(added)
+++
wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/internal/EnclosurePageExpectedResult_5.html
Wed Apr 2 03:10:50 2008
@@ -0,0 +1,10 @@
+<html>
+<body>
+This is in the super markup.<br>
+<wicket:child><wicket:extend>
+ <wicket:enclosure child="foo:bar"></wicket:enclosure>
+</wicket:extend></wicket:child>
+This is in the super markup.<br>
+</body>
+</html>
+
Added:
wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/internal/EnclosurePage_4.html
URL:
http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/internal/EnclosurePage_4.html?rev=643829&view=auto
==============================================================================
---
wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/internal/EnclosurePage_4.html
(added)
+++
wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/internal/EnclosurePage_4.html
Wed Apr 2 03:10:50 2008
@@ -0,0 +1,9 @@
+<html xmlns:wicket>
+<body>
+ <wicket:enclosure child="foo:bar">
+ <div wicket:id="foo">
+ <div wicket:id="bar">foobar</div>
+ </div>
+ </wicket:enclosure>
+</body>
+</html>
Added:
wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/internal/EnclosurePage_4.java
URL:
http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/internal/EnclosurePage_4.java?rev=643829&view=auto
==============================================================================
---
wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/internal/EnclosurePage_4.java
(added)
+++
wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/internal/EnclosurePage_4.java
Wed Apr 2 03:10:50 2008
@@ -0,0 +1,49 @@
+/*
+ * 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.internal;
+
+import org.apache.wicket.PageParameters;
+import org.apache.wicket.markup.html.WebMarkupContainer;
+import org.apache.wicket.markup.html.WebPage;
+import org.apache.wicket.markup.html.basic.Label;
+
+/**
+ * Mock page for testing.
+ *
+ */
+public class EnclosurePage_4 extends WebPage
+{
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * Construct.
+ *
+ * @param param
+ */
+ public EnclosurePage_4(PageParameters param)
+ {
+ final WebMarkupContainer foo = new WebMarkupContainer("foo");
+ final Label bar = new Label("bar", "bazqux");
+
+ // that one doesn't matter
+ boolean visible = param.getBoolean("visible");
+ bar.setVisible(visible);
+
+ foo.add(bar);
+ add(foo);
+ }
+}
Added:
wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/internal/EnclosurePage_5.html
URL:
http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/internal/EnclosurePage_5.html?rev=643829&view=auto
==============================================================================
---
wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/internal/EnclosurePage_5.html
(added)
+++
wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/internal/EnclosurePage_5.html
Wed Apr 2 03:10:50 2008
@@ -0,0 +1,7 @@
+<wicket:extend>
+ <wicket:enclosure child="foo:bar">
+ <div wicket:id="foo">
+ <div wicket:id="bar">foobar</div>
+ </div>
+ </wicket:enclosure>
+</wicket:extend>
\ No newline at end of file
Added:
wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/internal/EnclosurePage_5.java
URL:
http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/internal/EnclosurePage_5.java?rev=643829&view=auto
==============================================================================
---
wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/internal/EnclosurePage_5.java
(added)
+++
wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/internal/EnclosurePage_5.java
Wed Apr 2 03:10:50 2008
@@ -0,0 +1,48 @@
+/*
+ * 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.internal;
+
+import org.apache.wicket.PageParameters;
+import org.apache.wicket.markup.html.WebMarkupContainer;
+import org.apache.wicket.markup.html.basic.Label;
+
+/**
+ * Mock page for testing.
+ *
+ */
+public class EnclosurePage_5 extends EnclosurePage_5_Base
+{
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * Construct.
+ *
+ * @param param
+ */
+ public EnclosurePage_5(PageParameters param)
+ {
+ final WebMarkupContainer foo = new WebMarkupContainer("foo");
+ final Label bar = new Label("bar", "bazqux");
+
+ // that one doesn't matter
+ boolean visible = param.getBoolean("visible");
+ bar.setVisible(visible);
+
+ foo.add(bar);
+ add(foo);
+ }
+}
Added:
wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/internal/EnclosurePage_5_Base.html
URL:
http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/internal/EnclosurePage_5_Base.html?rev=643829&view=auto
==============================================================================
---
wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/internal/EnclosurePage_5_Base.html
(added)
+++
wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/internal/EnclosurePage_5_Base.html
Wed Apr 2 03:10:50 2008
@@ -0,0 +1,8 @@
+<html>
+<body>
+This is in the super markup.<br>
+<wicket:child />
+This is in the super markup.<br>
+</body>
+</html>
+
Added:
wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/internal/EnclosurePage_5_Base.java
URL:
http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/internal/EnclosurePage_5_Base.java?rev=643829&view=auto
==============================================================================
---
wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/internal/EnclosurePage_5_Base.java
(added)
+++
wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/internal/EnclosurePage_5_Base.java
Wed Apr 2 03:10:50 2008
@@ -0,0 +1,36 @@
+/*
+ * 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.internal;
+
+import org.apache.wicket.markup.html.WebPage;
+
+/**
+ * Mock page for testing.
+ *
+ */
+public class EnclosurePage_5_Base extends WebPage
+{
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * Construct.
+ *
+ */
+ public EnclosurePage_5_Base()
+ {
+ }
+}
Modified:
wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/internal/EnclosureTest.java
URL:
http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/internal/EnclosureTest.java?rev=643829&r1=643828&r2=643829&view=diff
==============================================================================
---
wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/internal/EnclosureTest.java
(original)
+++
wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/internal/EnclosureTest.java
Wed Apr 2 03:10:50 2008
@@ -16,6 +16,7 @@
*/
package org.apache.wicket.markup.html.internal;
+import org.apache.wicket.PageParameters;
import org.apache.wicket.WicketTestCase;
import org.apache.wicket.protocol.http.WebApplication;
import org.apache.wicket.resource.DummyApplication;
@@ -71,5 +72,41 @@
public void testRenderHomePage3() throws Exception
{
executeTest(EnclosurePage_3.class,
"EnclosurePageExpectedResult_3.html");
+ }
+
+ /**
+ * @throws Exception
+ */
+ public void testRenderHomePage4() throws Exception
+ {
+ executeTest(EnclosurePage_4.class, new
PageParameters("visible=false"),
+ "EnclosurePageExpectedResult_4.html");
+ }
+
+ /**
+ * @throws Exception
+ */
+ public void testRenderHomePage4_1() throws Exception
+ {
+ executeTest(EnclosurePage_4.class, new
PageParameters("visible=true"),
+ "EnclosurePageExpectedResult_4-1.html");
+ }
+
+ /**
+ * @throws Exception
+ */
+ public void testRenderHomePage5() throws Exception
+ {
+ executeTest(EnclosurePage_5.class, new
PageParameters("visible=false"),
+ "EnclosurePageExpectedResult_5.html");
+ }
+
+ /**
+ * @throws Exception
+ */
+ public void testRenderHomePage5_1() throws Exception
+ {
+ executeTest(EnclosurePage_5.class, new
PageParameters("visible=true"),
+ "EnclosurePageExpectedResult_5-1.html");
}
}