You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by jd...@apache.org on 2011/07/03 12:42:05 UTC
svn commit: r1142411 - in /wicket/trunk/wicket-core/src:
main/java/org/apache/wicket/
main/java/org/apache/wicket/markup/html/internal/
test/java/org/apache/wicket/markup/html/internal/
Author: jdonnerstag
Date: Sun Jul 3 10:42:04 2011
New Revision: 1142411
URL: http://svn.apache.org/viewvc?rev=1142411&view=rev
Log:
fixed: Components inside an invisible <wicket:enclosure> are still rendered
Issue: WICKET-3833
Added:
wicket/trunk/wicket-core/src/test/java/org/apache/wicket/markup/html/internal/EnclosurePageExpectedResult_12.html
wicket/trunk/wicket-core/src/test/java/org/apache/wicket/markup/html/internal/EnclosurePageExpectedResult_13.html
wicket/trunk/wicket-core/src/test/java/org/apache/wicket/markup/html/internal/EnclosurePage_12.html
wicket/trunk/wicket-core/src/test/java/org/apache/wicket/markup/html/internal/EnclosurePage_12.java
wicket/trunk/wicket-core/src/test/java/org/apache/wicket/markup/html/internal/EnclosurePage_13.html
wicket/trunk/wicket-core/src/test/java/org/apache/wicket/markup/html/internal/EnclosurePage_13.java
wicket/trunk/wicket-core/src/test/java/org/apache/wicket/markup/html/internal/SecuredContainer_13.java
Modified:
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/MarkupContainer.java
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/Page.java
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/markup/html/internal/Enclosure.java
wicket/trunk/wicket-core/src/test/java/org/apache/wicket/markup/html/internal/EnclosurePageExpectedResult_1.html
wicket/trunk/wicket-core/src/test/java/org/apache/wicket/markup/html/internal/EnclosurePageExpectedResult_2.html
wicket/trunk/wicket-core/src/test/java/org/apache/wicket/markup/html/internal/EnclosurePageExpectedResult_4.html
wicket/trunk/wicket-core/src/test/java/org/apache/wicket/markup/html/internal/EnclosurePageExpectedResult_5.html
wicket/trunk/wicket-core/src/test/java/org/apache/wicket/markup/html/internal/EnclosurePageExpectedResult_9-1.html
wicket/trunk/wicket-core/src/test/java/org/apache/wicket/markup/html/internal/EnclosurePageExpectedResult_9-2-1.html
wicket/trunk/wicket-core/src/test/java/org/apache/wicket/markup/html/internal/EnclosurePageExpectedResult_9-2.html
wicket/trunk/wicket-core/src/test/java/org/apache/wicket/markup/html/internal/EnclosureTest.java
wicket/trunk/wicket-core/src/test/java/org/apache/wicket/markup/html/internal/InlineEnclosurePageExpectedResult_1.html
Modified: wicket/trunk/wicket-core/src/main/java/org/apache/wicket/MarkupContainer.java
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket-core/src/main/java/org/apache/wicket/MarkupContainer.java?rev=1142411&r1=1142410&r2=1142411&view=diff
==============================================================================
--- wicket/trunk/wicket-core/src/main/java/org/apache/wicket/MarkupContainer.java (original)
+++ wicket/trunk/wicket-core/src/main/java/org/apache/wicket/MarkupContainer.java Sun Jul 3 10:42:04 2011
@@ -40,6 +40,7 @@ import org.apache.wicket.model.IComponen
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.IWrapModel;
import org.apache.wicket.settings.IDebugSettings;
+import org.apache.wicket.util.iterator.ComponentHierarchyIterator;
import org.apache.wicket.util.lang.Args;
import org.apache.wicket.util.lang.Generics;
import org.apache.wicket.util.string.ComponentStrings;
@@ -904,6 +905,25 @@ public abstract class MarkupContainer ex
}
/**
+ * @return A iterator which iterators over all children and grand-children the Component
+ */
+ public final ComponentHierarchyIterator visitChildren()
+ {
+ return new ComponentHierarchyIterator(this);
+ }
+
+ /**
+ * @param clazz
+ * Filter condition
+ * @return A iterator which iterators over all children and grand-children the Component,
+ * returning only components which implement (instanceof) the provided clazz.
+ */
+ public final ComponentHierarchyIterator visitChildren(final Class<?> clazz)
+ {
+ return new ComponentHierarchyIterator(this).filterByClass(clazz);
+ }
+
+ /**
* @param child
* Component being added
*/
Modified: wicket/trunk/wicket-core/src/main/java/org/apache/wicket/Page.java
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket-core/src/main/java/org/apache/wicket/Page.java?rev=1142411&r1=1142410&r2=1142411&view=diff
==============================================================================
--- wicket/trunk/wicket-core/src/main/java/org/apache/wicket/Page.java (original)
+++ wicket/trunk/wicket-core/src/main/java/org/apache/wicket/Page.java Sun Jul 3 10:42:04 2011
@@ -40,6 +40,7 @@ import org.apache.wicket.session.ISessio
import org.apache.wicket.settings.IDebugSettings;
import org.apache.wicket.settings.IRequestCycleSettings.RenderStrategy;
import org.apache.wicket.util.lang.Classes;
+import org.apache.wicket.util.lang.Generics;
import org.apache.wicket.util.lang.WicketObjects;
import org.apache.wicket.util.string.StringValue;
import org.apache.wicket.util.visit.IVisit;
@@ -687,10 +688,9 @@ public abstract class Page extends Marku
// Throw exception if any errors were found
if (unrenderedComponents.size() > 0)
{
- // Get rid of set
renderedComponents = null;
- List<Component> transparentContainerChildren = new ArrayList<Component>();
+ List<Component> transparentContainerChildren = Generics.newArrayList();
Iterator<Component> iterator = unrenderedComponents.iterator();
outerWhile : while (iterator.hasNext())
@@ -713,29 +713,23 @@ public abstract class Page extends Marku
}
}
- // Now first test if the component has a sibling that is a transparent resolver.
- for (Object o : component.getParent())
+ if (hasInvisibleTransparentChild(component.getParent(), component))
{
- Component sibling = (Component)o;
- if (!sibling.isVisible())
+ // If we found a transparent container that isn't visible then ignore this
+ // component and only do a debug statement here.
+ if (log.isDebugEnabled())
{
- if (sibling instanceof IComponentResolver)
- {
- // we found a transparent container that isn't visible
- // then ignore this component and only do a debug statement here.
- if (log.isDebugEnabled())
- {
- log.debug(
- "Component {} wasn't rendered but most likely it has a transparent parent: {}",
- component, sibling);
- }
- transparentContainerChildren.add(component);
- iterator.remove();
- continue outerWhile;
- }
+ log.debug(
+ "Component {} wasn't rendered but might have a transparent parent.",
+ component);
}
+
+ transparentContainerChildren.add(component);
+ iterator.remove();
+ continue outerWhile;
}
}
+
// if still > 0
if (unrenderedComponents.size() > 0)
{
@@ -751,6 +745,31 @@ public abstract class Page extends Marku
renderedComponents = null;
}
+ private boolean hasInvisibleTransparentChild(final MarkupContainer root, final Component self)
+ {
+ for (Component sibling : root)
+ {
+ if ((sibling != self) && (sibling instanceof IComponentResolver) &&
+ (sibling instanceof MarkupContainer))
+ {
+ if (!sibling.isVisible())
+ {
+ return true;
+ }
+ else
+ {
+ boolean rtn = hasInvisibleTransparentChild((MarkupContainer)sibling, self);
+ if (rtn == true)
+ {
+ return true;
+ }
+ }
+ }
+ }
+
+ return false;
+ }
+
/**
* Initializes Page by adding it to the Session and initializing it.
*/
Modified: wicket/trunk/wicket-core/src/main/java/org/apache/wicket/markup/html/internal/Enclosure.java
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket-core/src/main/java/org/apache/wicket/markup/html/internal/Enclosure.java?rev=1142411&r1=1142410&r2=1142411&view=diff
==============================================================================
--- wicket/trunk/wicket-core/src/main/java/org/apache/wicket/markup/html/internal/Enclosure.java (original)
+++ wicket/trunk/wicket-core/src/main/java/org/apache/wicket/markup/html/internal/Enclosure.java Sun Jul 3 10:42:04 2011
@@ -19,22 +19,15 @@ package org.apache.wicket.markup.html.in
import org.apache.wicket.Component;
import org.apache.wicket.MarkupContainer;
import org.apache.wicket.WicketRuntimeException;
-import org.apache.wicket.application.IComponentOnAfterRenderListener;
import org.apache.wicket.markup.ComponentTag;
import org.apache.wicket.markup.MarkupException;
import org.apache.wicket.markup.MarkupStream;
import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.markup.html.basic.EnclosureContainer;
-import org.apache.wicket.markup.html.form.Form;
-import org.apache.wicket.markup.html.form.FormComponent;
-import org.apache.wicket.markup.html.form.IFormSubmittingComponent;
import org.apache.wicket.markup.parser.filter.EnclosureHandler;
import org.apache.wicket.markup.resolver.ComponentResolvers;
import org.apache.wicket.markup.resolver.ComponentResolvers.ResolverFilter;
import org.apache.wicket.markup.resolver.IComponentResolver;
-import org.apache.wicket.request.Response;
-import org.apache.wicket.request.cycle.RequestCycle;
-import org.apache.wicket.response.NullResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -139,6 +132,12 @@ public class Enclosure extends WebMarkup
return childComponent;
}
+ @Override
+ public boolean isVisible()
+ {
+ return childComponent.determineVisibility() && super.isVisible();
+ }
+
/**
* Get the real parent container
*
@@ -160,48 +159,6 @@ public class Enclosure extends WebMarkup
return parent;
}
- @Override
- public void onComponentTagBody(final MarkupStream markupStream, final ComponentTag openTag)
- {
- // TODO this is where I wish we had something like "enum(TAG, BODY, NONE, ALL) isVisible()"
- // set the enclosure visibility
- boolean visible = childComponent.determineVisibility();
-
- // We want to know which components are rendered inside the enclosure
- final IComponentOnAfterRenderListener listener = new EnclosureListener(this);
-
- try
- {
- // register the listener
- getApplication().getComponentOnAfterRenderListeners().add(listener);
-
- if (visible)
- {
- super.onComponentTagBody(markupStream, openTag);
- }
- else
- {
- RequestCycle cycle = getRequestCycle();
- Response response = cycle.getResponse();
- try
- {
- cycle.setResponse(NullResponse.getInstance());
-
- super.onComponentTagBody(markupStream, openTag);
- }
- finally
- {
- cycle.setResponse(response);
- }
- }
- }
- finally
- {
- // make sure we remove the listener
- getApplication().getComponentOnAfterRenderListeners().remove(listener);
- }
- }
-
/**
* @param markupStream
* @param container
@@ -276,31 +233,4 @@ public class Enclosure extends WebMarkup
"Programming error: childComponent == enclose component; endless loop");
}
}
-
- /**
- * Enclosure will register this listener during the body render phase of the Enclosure
- */
- private static class EnclosureListener implements IComponentOnAfterRenderListener
- {
- private final Enclosure enclosure;
-
- private EnclosureListener(final Enclosure enclosure)
- {
- this.enclosure = enclosure;
- }
-
- public void onAfterRender(final Component component)
- {
- if (log.isWarnEnabled())
- {
- if ((component instanceof FormComponent) ||
- (component instanceof IFormSubmittingComponent) || (component instanceof Form))
- {
- log.warn("Please note that onBeforeRender() and validate() might be called on invisible components inside an Enclosure. " +
- "Please see EnclosureContainer for an alternative. Enclosure: " +
- enclosure.toString());
- }
- }
- }
- }
}
Modified: wicket/trunk/wicket-core/src/test/java/org/apache/wicket/markup/html/internal/EnclosurePageExpectedResult_1.html
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket-core/src/test/java/org/apache/wicket/markup/html/internal/EnclosurePageExpectedResult_1.html?rev=1142411&r1=1142410&r2=1142411&view=diff
==============================================================================
--- wicket/trunk/wicket-core/src/test/java/org/apache/wicket/markup/html/internal/EnclosurePageExpectedResult_1.html (original)
+++ wicket/trunk/wicket-core/src/test/java/org/apache/wicket/markup/html/internal/EnclosurePageExpectedResult_1.html Sun Jul 3 10:42:04 2011
@@ -8,7 +8,7 @@
<table><tr><span wicket:id="label2">Test Label 2</span></tr></table>
</wicket:enclosure>
- <wicket:enclosure child="label3"></wicket:enclosure>
+
<wicket:enclosure child="label6">
<table><tr><span wicket:id="label4">Test Label 2</span></tr></table>
Added: wicket/trunk/wicket-core/src/test/java/org/apache/wicket/markup/html/internal/EnclosurePageExpectedResult_12.html
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket-core/src/test/java/org/apache/wicket/markup/html/internal/EnclosurePageExpectedResult_12.html?rev=1142411&view=auto
==============================================================================
--- wicket/trunk/wicket-core/src/test/java/org/apache/wicket/markup/html/internal/EnclosurePageExpectedResult_12.html (added)
+++ wicket/trunk/wicket-core/src/test/java/org/apache/wicket/markup/html/internal/EnclosurePageExpectedResult_12.html Sun Jul 3 10:42:04 2011
@@ -0,0 +1,6 @@
+<!DOCTYPE html>
+<html xmlns:wicket="http://wicket.apache.org">
+<body>
+
+</body>
+</html>
Added: wicket/trunk/wicket-core/src/test/java/org/apache/wicket/markup/html/internal/EnclosurePageExpectedResult_13.html
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket-core/src/test/java/org/apache/wicket/markup/html/internal/EnclosurePageExpectedResult_13.html?rev=1142411&view=auto
==============================================================================
--- wicket/trunk/wicket-core/src/test/java/org/apache/wicket/markup/html/internal/EnclosurePageExpectedResult_13.html (added)
+++ wicket/trunk/wicket-core/src/test/java/org/apache/wicket/markup/html/internal/EnclosurePageExpectedResult_13.html Sun Jul 3 10:42:04 2011
@@ -0,0 +1,6 @@
+<!DOCTYPE html>
+<html xmlns:wicket="http://wicket.apache.org">
+<body>
+
+</body>
+</html>
Modified: wicket/trunk/wicket-core/src/test/java/org/apache/wicket/markup/html/internal/EnclosurePageExpectedResult_2.html
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket-core/src/test/java/org/apache/wicket/markup/html/internal/EnclosurePageExpectedResult_2.html?rev=1142411&r1=1142410&r2=1142411&view=diff
==============================================================================
--- wicket/trunk/wicket-core/src/test/java/org/apache/wicket/markup/html/internal/EnclosurePageExpectedResult_2.html (original)
+++ wicket/trunk/wicket-core/src/test/java/org/apache/wicket/markup/html/internal/EnclosurePageExpectedResult_2.html Sun Jul 3 10:42:04 2011
@@ -4,7 +4,7 @@
<h3>Example 3 using wicket:enclosure</h3>
<span wicket:id="label1">label 1</span><br />
<span wicket:id="label2">label 2</span><br />
- <wicket:enclosure child="label3"></wicket:enclosure>
+
</div>
</body>
</html>
Modified: wicket/trunk/wicket-core/src/test/java/org/apache/wicket/markup/html/internal/EnclosurePageExpectedResult_4.html
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket-core/src/test/java/org/apache/wicket/markup/html/internal/EnclosurePageExpectedResult_4.html?rev=1142411&r1=1142410&r2=1142411&view=diff
==============================================================================
--- wicket/trunk/wicket-core/src/test/java/org/apache/wicket/markup/html/internal/EnclosurePageExpectedResult_4.html (original)
+++ wicket/trunk/wicket-core/src/test/java/org/apache/wicket/markup/html/internal/EnclosurePageExpectedResult_4.html Sun Jul 3 10:42:04 2011
@@ -1,5 +1,5 @@
<html xmlns:wicket>
<body>
- <wicket:enclosure child="foo:bar"></wicket:enclosure>
+
</body>
</html>
Modified: wicket/trunk/wicket-core/src/test/java/org/apache/wicket/markup/html/internal/EnclosurePageExpectedResult_5.html
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket-core/src/test/java/org/apache/wicket/markup/html/internal/EnclosurePageExpectedResult_5.html?rev=1142411&r1=1142410&r2=1142411&view=diff
==============================================================================
--- wicket/trunk/wicket-core/src/test/java/org/apache/wicket/markup/html/internal/EnclosurePageExpectedResult_5.html (original)
+++ wicket/trunk/wicket-core/src/test/java/org/apache/wicket/markup/html/internal/EnclosurePageExpectedResult_5.html Sun Jul 3 10:42:04 2011
@@ -2,7 +2,7 @@
<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>
Modified: wicket/trunk/wicket-core/src/test/java/org/apache/wicket/markup/html/internal/EnclosurePageExpectedResult_9-1.html
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket-core/src/test/java/org/apache/wicket/markup/html/internal/EnclosurePageExpectedResult_9-1.html?rev=1142411&r1=1142410&r2=1142411&view=diff
==============================================================================
--- wicket/trunk/wicket-core/src/test/java/org/apache/wicket/markup/html/internal/EnclosurePageExpectedResult_9-1.html (original)
+++ wicket/trunk/wicket-core/src/test/java/org/apache/wicket/markup/html/internal/EnclosurePageExpectedResult_9-1.html Sun Jul 3 10:42:04 2011
@@ -2,7 +2,7 @@
<body>
<form wicket:id="form" id="form1" method="post" action="page?1-1.IFormSubmitListener-form"><div style="width:0px;height:0px;position:absolute;left:-100px;top:-100px;overflow:hidden"><input type="hidden" name="form1_hf_0" id="form1_hf_0" /></div>
<!-- does Wicket behave different if the enclosure child is a FormComponent?? Needs testing -->
- <wicket:enclosure child="label"></wicket:enclosure>
+
</form>
</body>
</html>
Modified: wicket/trunk/wicket-core/src/test/java/org/apache/wicket/markup/html/internal/EnclosurePageExpectedResult_9-2-1.html
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket-core/src/test/java/org/apache/wicket/markup/html/internal/EnclosurePageExpectedResult_9-2-1.html?rev=1142411&r1=1142410&r2=1142411&view=diff
==============================================================================
--- wicket/trunk/wicket-core/src/test/java/org/apache/wicket/markup/html/internal/EnclosurePageExpectedResult_9-2-1.html (original)
+++ wicket/trunk/wicket-core/src/test/java/org/apache/wicket/markup/html/internal/EnclosurePageExpectedResult_9-2-1.html Sun Jul 3 10:42:04 2011
@@ -2,7 +2,7 @@
<body>
<form wicket:id="form" id="form1" method="post" action="page?2-1.IFormSubmitListener-form"><div style="width:0px;height:0px;position:absolute;left:-100px;top:-100px;overflow:hidden"><input type="hidden" name="form1_hf_0" id="form1_hf_0" /></div>
<!-- does Wicket behave different if the enclosure child is a FormComponent?? Needs testing -->
- <wicket:enclosure child="label"></wicket:enclosure>
+
</form>
</body>
</html>
Modified: wicket/trunk/wicket-core/src/test/java/org/apache/wicket/markup/html/internal/EnclosurePageExpectedResult_9-2.html
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket-core/src/test/java/org/apache/wicket/markup/html/internal/EnclosurePageExpectedResult_9-2.html?rev=1142411&r1=1142410&r2=1142411&view=diff
==============================================================================
--- wicket/trunk/wicket-core/src/test/java/org/apache/wicket/markup/html/internal/EnclosurePageExpectedResult_9-2.html (original)
+++ wicket/trunk/wicket-core/src/test/java/org/apache/wicket/markup/html/internal/EnclosurePageExpectedResult_9-2.html Sun Jul 3 10:42:04 2011
@@ -1,8 +1,8 @@
-<html xmlns:wicket>
-<body>
- <form wicket:id="form" id="form1" method="post" action="page?4-1.IFormSubmitListener-form"><div style="width:0px;height:0px;position:absolute;left:-100px;top:-100px;overflow:hidden"><input type="hidden" name="form1_hf_0" id="form1_hf_0" /></div>
- <!-- does Wicket behave different if the enclosure child is a FormComponent?? Needs testing -->
- <wicket:enclosure child="label"></wicket:enclosure>
- </form>
-</body>
-</html>
+<html xmlns:wicket>
+<body>
+ <form wicket:id="form" id="form1" method="post" action="page?4-1.IFormSubmitListener-form"><div style="width:0px;height:0px;position:absolute;left:-100px;top:-100px;overflow:hidden"><input type="hidden" name="form1_hf_0" id="form1_hf_0" /></div>
+ <!-- does Wicket behave different if the enclosure child is a FormComponent?? Needs testing -->
+
+ </form>
+</body>
+</html>
Added: wicket/trunk/wicket-core/src/test/java/org/apache/wicket/markup/html/internal/EnclosurePage_12.html
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket-core/src/test/java/org/apache/wicket/markup/html/internal/EnclosurePage_12.html?rev=1142411&view=auto
==============================================================================
--- wicket/trunk/wicket-core/src/test/java/org/apache/wicket/markup/html/internal/EnclosurePage_12.html (added)
+++ wicket/trunk/wicket-core/src/test/java/org/apache/wicket/markup/html/internal/EnclosurePage_12.html Sun Jul 3 10:42:04 2011
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<html xmlns:wicket="http://wicket.apache.org">
+<body>
+ <wicket:enclosure child="invisible">
+ This entire enclosure should be hidden.
+ <p wicket:id="invisible"></p>
+ <p wicket:id="shouldntrendereither">
+ <span wicket:id="label"></span>
+ </p>
+ </wicket:enclosure>
+</body>
+</html>
Added: wicket/trunk/wicket-core/src/test/java/org/apache/wicket/markup/html/internal/EnclosurePage_12.java
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket-core/src/test/java/org/apache/wicket/markup/html/internal/EnclosurePage_12.java?rev=1142411&view=auto
==============================================================================
--- wicket/trunk/wicket-core/src/test/java/org/apache/wicket/markup/html/internal/EnclosurePage_12.java (added)
+++ wicket/trunk/wicket-core/src/test/java/org/apache/wicket/markup/html/internal/EnclosurePage_12.java Sun Jul 3 10:42:04 2011
@@ -0,0 +1,61 @@
+/*
+ * 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.WebMarkupContainer;
+import org.apache.wicket.markup.html.WebPage;
+import org.apache.wicket.markup.html.basic.Label;
+import org.apache.wicket.model.PropertyModel;
+import org.apache.wicket.request.mapper.parameter.PageParameters;
+
+/** */
+public class EnclosurePage_12 extends WebPage
+{
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * Construct.
+ *
+ * @param parameters
+ */
+ public EnclosurePage_12(final PageParameters parameters)
+ {
+ add(new Label("version", getApplication().getFrameworkSettings().getVersion()));
+ // TODO Add your page's components here
+
+ // Here are two components.
+
+ // Both are contained within <wicket:enclosure child="invisible">.
+ // Since the "invisible" component is explicitly hidden, the expecation is
+ // that the whole enclosure will be hidden as well. Furthermore this implies
+ // that none of the components within the enclosure will be rendered.
+
+ // However this is not the case. Even though the "shouldntrendereither"
+ // component is in the same enclosure and therefore should not be rendered,
+ // Wicket attempts to render it. This is evidenced by the fact that we've
+ // purposely included a Label that will blow up when its model is loaded.
+
+ // When this page is loaded we get the exception:
+ // WicketRuntimeException: ... nonexistentprop
+
+ // Wicket 1.4.x does not have this problem.
+
+ add(new WebMarkupContainer("invisible").setVisible(false));
+ add(new WebMarkupContainer("shouldntrendereither").add(new Label("label",
+ new PropertyModel<String>(this, "nonexistentprop"))));
+ }
+}
Added: wicket/trunk/wicket-core/src/test/java/org/apache/wicket/markup/html/internal/EnclosurePage_13.html
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket-core/src/test/java/org/apache/wicket/markup/html/internal/EnclosurePage_13.html?rev=1142411&view=auto
==============================================================================
--- wicket/trunk/wicket-core/src/test/java/org/apache/wicket/markup/html/internal/EnclosurePage_13.html (added)
+++ wicket/trunk/wicket-core/src/test/java/org/apache/wicket/markup/html/internal/EnclosurePage_13.html Sun Jul 3 10:42:04 2011
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<html xmlns:wicket="http://wicket.apache.org">
+<body>
+ <wicket:enclosure child="invisible">
+ This entire enclosure should be hidden.
+ <p wicket:id="invisible"></p>
+ <p wicket:id="shouldntrendereither">
+ <span wicket:id="label"></span>
+ </p>
+ </wicket:enclosure>
+</body>
+</html>
Added: wicket/trunk/wicket-core/src/test/java/org/apache/wicket/markup/html/internal/EnclosurePage_13.java
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket-core/src/test/java/org/apache/wicket/markup/html/internal/EnclosurePage_13.java?rev=1142411&view=auto
==============================================================================
--- wicket/trunk/wicket-core/src/test/java/org/apache/wicket/markup/html/internal/EnclosurePage_13.java (added)
+++ wicket/trunk/wicket-core/src/test/java/org/apache/wicket/markup/html/internal/EnclosurePage_13.java Sun Jul 3 10:42:04 2011
@@ -0,0 +1,63 @@
+/*
+ * 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.WebMarkupContainer;
+import org.apache.wicket.markup.html.WebPage;
+import org.apache.wicket.markup.html.basic.Label;
+import org.apache.wicket.model.PropertyModel;
+import org.apache.wicket.request.mapper.parameter.PageParameters;
+
+
+/** */
+public class EnclosurePage_13 extends WebPage
+{
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * Construct.
+ *
+ * @param parameters
+ */
+ public EnclosurePage_13(final PageParameters parameters)
+ {
+ add(new Label("version", getApplication().getFrameworkSettings().getVersion()));
+ // TODO Add your page's components here
+
+ // Here are two components.
+
+ // Both are contained within <wicket:enclosure child="invisible">.
+ // Since the "invisible" component is hidden (in this case due to
+ // isRenderAllowed() == false), the expecation is
+ // that the whole enclosure will be hidden as well. Furthermore this implies
+ // that none of the components within the enclosure will be rendered.
+
+ // However this is not the case. Even though the "shouldntrendereither"
+ // component is in the same enclosure and therefore should not be rendered,
+ // Wicket attempts to render it. This is evidenced by the fact that we've
+ // purposely included a Label that will blow up when its model is loaded.
+
+ // When this page is loaded we get the exception:
+ // WicketRuntimeException: ... nonexistentprop
+
+ // Wicket 1.4.x does not have this problem.
+
+ add(new SecuredContainer_13("invisible"));
+ add(new WebMarkupContainer("shouldntrendereither").add(new Label("label",
+ new PropertyModel<String>(this, "nonexistentprop"))));
+ }
+}
Modified: wicket/trunk/wicket-core/src/test/java/org/apache/wicket/markup/html/internal/EnclosureTest.java
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket-core/src/test/java/org/apache/wicket/markup/html/internal/EnclosureTest.java?rev=1142411&r1=1142410&r2=1142411&view=diff
==============================================================================
--- wicket/trunk/wicket-core/src/test/java/org/apache/wicket/markup/html/internal/EnclosureTest.java (original)
+++ wicket/trunk/wicket-core/src/test/java/org/apache/wicket/markup/html/internal/EnclosureTest.java Sun Jul 3 10:42:04 2011
@@ -18,12 +18,18 @@ package org.apache.wicket.markup.html.in
import java.io.IOException;
+import org.apache.wicket.Component;
import org.apache.wicket.Page;
import org.apache.wicket.WicketTestCase;
+import org.apache.wicket.authorization.Action;
+import org.apache.wicket.authorization.IAuthorizationStrategy;
import org.apache.wicket.markup.html.form.CheckBox;
+import org.apache.wicket.mock.MockApplication;
+import org.apache.wicket.request.component.IRequestableComponent;
import org.apache.wicket.request.mapper.parameter.PageParameters;
import org.apache.wicket.util.tester.DiffUtil;
import org.apache.wicket.util.tester.FormTester;
+import org.apache.wicket.util.tester.WicketTester;
/**
@@ -301,4 +307,44 @@ public class EnclosureTest extends Wicke
{
executeTest(EnclosurePage_11.class, "EnclosurePageExpectedResult_11.html");
}
+
+ /**
+ * @throws Exception
+ */
+ public void testRenderPage12() throws Exception
+ {
+ executeTest(EnclosurePage_12.class, "EnclosurePageExpectedResult_12.html");
+ }
+
+ /**
+ * @throws Exception
+ */
+ public void testRenderPage13() throws Exception
+ {
+ tester = new WicketTester(new MockApplication()
+ {
+ @Override
+ protected void init()
+ {
+ super.init();
+
+ // This should cause all SecuredContainer components to be hidden
+ getSecuritySettings().setAuthorizationStrategy(new IAuthorizationStrategy()
+ {
+ public boolean isActionAuthorized(Component component, Action action)
+ {
+ return !(component instanceof SecuredContainer_13);
+ }
+
+ public <T extends IRequestableComponent> boolean isInstantiationAuthorized(
+ Class<T> componentClass)
+ {
+ return true;
+ }
+ });
+ }
+ });
+
+ executeTest(EnclosurePage_13.class, "EnclosurePageExpectedResult_13.html");
+ }
}
Modified: wicket/trunk/wicket-core/src/test/java/org/apache/wicket/markup/html/internal/InlineEnclosurePageExpectedResult_1.html
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket-core/src/test/java/org/apache/wicket/markup/html/internal/InlineEnclosurePageExpectedResult_1.html?rev=1142411&r1=1142410&r2=1142411&view=diff
==============================================================================
--- wicket/trunk/wicket-core/src/test/java/org/apache/wicket/markup/html/internal/InlineEnclosurePageExpectedResult_1.html (original)
+++ wicket/trunk/wicket-core/src/test/java/org/apache/wicket/markup/html/internal/InlineEnclosurePageExpectedResult_1.html Sun Jul 3 10:42:04 2011
@@ -11,7 +11,7 @@
</table>
</div>
-<span id="InlineEnclosure-3"></span>
+<span id="InlineEnclosure-3" style="display:none"></span>
<div id="InlineEnclosure-4">
<table>
Added: wicket/trunk/wicket-core/src/test/java/org/apache/wicket/markup/html/internal/SecuredContainer_13.java
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket-core/src/test/java/org/apache/wicket/markup/html/internal/SecuredContainer_13.java?rev=1142411&view=auto
==============================================================================
--- wicket/trunk/wicket-core/src/test/java/org/apache/wicket/markup/html/internal/SecuredContainer_13.java (added)
+++ wicket/trunk/wicket-core/src/test/java/org/apache/wicket/markup/html/internal/SecuredContainer_13.java Sun Jul 3 10:42:04 2011
@@ -0,0 +1,35 @@
+/*
+ * 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.WebMarkupContainer;
+
+/** */
+public class SecuredContainer_13 extends WebMarkupContainer
+{
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * Construct.
+ *
+ * @param id
+ */
+ public SecuredContainer_13(String id)
+ {
+ super(id);
+ }
+}