Author: jdonnerstag
Date: Sat Jul  9 09:28:19 2011
New Revision: 1144622

URL: http://svn.apache.org/viewvc?rev=1144622&view=rev
Log:
fixed: The wicket:enclosure attribute doesn't work properly
Issue: WICKET-3842

Modified:
    
wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/markup/html/internal/InlineEnclosure.java
    
wicket/branches/wicket-1.4.x/wicket/src/test/java/org/apache/wicket/markup/html/internal/EnclosureTest.java
    
wicket/branches/wicket-1.4.x/wicket/src/test/java/org/apache/wicket/markup/html/internal/InlineEnclosurePageExpectedResult_1.html

Modified: 
wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/markup/html/internal/InlineEnclosure.java
URL: 
http://svn.apache.org/viewvc/wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/markup/html/internal/InlineEnclosure.java?rev=1144622&r1=1144621&r2=1144622&view=diff
==============================================================================
--- 
wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/markup/html/internal/InlineEnclosure.java
 (original)
+++ 
wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/markup/html/internal/InlineEnclosure.java
 Sat Jul  9 09:28:19 2011
@@ -69,6 +69,14 @@ public class InlineEnclosure extends Enc
        }
 
        @Override
+       public boolean isVisible()
+       {
+               updateVisibility();
+
+               return super.isVisible();
+       }
+
+       @Override
        protected void onAfterRenderChildren()
        {
                if (children == null)
@@ -107,6 +115,12 @@ public class InlineEnclosure extends Enc
        public boolean updateVisibility()
        {
                Component child = getChildComponent();
+               if (child == null)
+               {
+                       throw new WicketRuntimeException("Could not find child 
with id: " + childId +
+                               " in the wicket:enclosure");
+               }
+
                boolean visible = child.isVisible();
                setVisible(visible);
                return visible;

Modified: 
wicket/branches/wicket-1.4.x/wicket/src/test/java/org/apache/wicket/markup/html/internal/EnclosureTest.java
URL: 
http://svn.apache.org/viewvc/wicket/branches/wicket-1.4.x/wicket/src/test/java/org/apache/wicket/markup/html/internal/EnclosureTest.java?rev=1144622&r1=1144621&r2=1144622&view=diff
==============================================================================
--- 
wicket/branches/wicket-1.4.x/wicket/src/test/java/org/apache/wicket/markup/html/internal/EnclosureTest.java
 (original)
+++ 
wicket/branches/wicket-1.4.x/wicket/src/test/java/org/apache/wicket/markup/html/internal/EnclosureTest.java
 Sat Jul  9 09:28:19 2011
@@ -28,6 +28,7 @@ import org.apache.wicket.markup.html.Web
 import org.apache.wicket.markup.html.WebPage;
 import org.apache.wicket.markup.html.basic.Label;
 import org.apache.wicket.markup.html.form.CheckBox;
+import org.apache.wicket.markup.html.link.Link;
 import org.apache.wicket.protocol.http.WebApplication;
 import org.apache.wicket.resource.DummyApplication;
 import org.apache.wicket.util.diff.DiffUtil;
@@ -339,6 +340,9 @@ public class EnclosureTest extends Wicke
                executeTest(EnclosurePage_11.class, 
"EnclosurePageExpectedResult_11.html");
        }
 
+       /**
+        * 
+        */
        public void testBadEnclosure1()
        {
                class TestPage extends WebPage implements 
IMarkupResourceStreamProvider
@@ -366,4 +370,48 @@ public class EnclosureTest extends Wicke
                        assertTrue(e.getMessage().startsWith("Could not find 
child"));
                }
        }
+
+       /**
+        * 
+        */
+       public void testAttribute()
+       {
+               class TestPage extends WebPage implements 
IMarkupResourceStreamProvider
+               {
+                       public TestPage()
+                       {
+                               final Label l = new Label("msg", "$label$");
+                               add(l);
+                               add(new Link<Void>("b")
+                               {
+                                       private static final long 
serialVersionUID = 1L;
+
+                                       @Override
+                                       public void onClick()
+                                       {
+                                               l.setVisible(!l.isVisible());
+                                       }
+                               });
+                       }
+
+                       public IResourceStream 
getMarkupResourceStream(MarkupContainer container,
+                               Class<?> containerClass)
+                       {
+                               return new StringResourceStream(
+                                       "<html><body><div 
wicket:enclosure='msg'><span wicket:id='msg'></span></div><input type='button' 
value='Toggle' wicket:id='b'></body></html>");
+                       }
+               }
+
+               tester.startPage(new TestPage());
+               
assertTrue(tester.getServletResponse().getDocument().contains("$label$"));
+
+               // toggle visibility of enclosure to false
+               tester.clickLink("b");
+               
assertFalse(tester.getServletResponse().getDocument().contains("$label$"));
+
+               // toggle visibility of enclosure to back to true
+               tester.clickLink("b");
+               
assertTrue(tester.getServletResponse().getDocument().contains("$label$"));
+
+       }
 }

Modified: 
wicket/branches/wicket-1.4.x/wicket/src/test/java/org/apache/wicket/markup/html/internal/InlineEnclosurePageExpectedResult_1.html
URL: 
http://svn.apache.org/viewvc/wicket/branches/wicket-1.4.x/wicket/src/test/java/org/apache/wicket/markup/html/internal/InlineEnclosurePageExpectedResult_1.html?rev=1144622&r1=1144621&r2=1144622&view=diff
==============================================================================
--- 
wicket/branches/wicket-1.4.x/wicket/src/test/java/org/apache/wicket/markup/html/internal/InlineEnclosurePageExpectedResult_1.html
 (original)
+++ 
wicket/branches/wicket-1.4.x/wicket/src/test/java/org/apache/wicket/markup/html/internal/InlineEnclosurePageExpectedResult_1.html
 Sat Jul  9 09:28:19 2011
@@ -1,48 +1,48 @@
-<html>
-<body>
-
-<span id="inlineEnclosure-1"> <span>Test Label 1</span> </span>
-
-<div id="inlineEnclosure-2">
-       <table>
-               <tr>
-                       <td><span>Test Label 2</span></td>
-               </tr>
-       </table>
-</div>
-
-<span id="inlineEnclosure-3"></span>
-
-<div id="inlineEnclosure-4">
-       <table>
-               <tr>
-                       <td><span>Test Label 4</span></td>
-               </tr>
-       </table>
-       <table>
-               <tr>
-                       <td><span>Test Label 5</span></td>
-               </tr>
-       </table>
-       <table>
-               <tr>
-                       <td><span>Test Label 6</span></td>
-               </tr>
-       </table>
-       <table>
-               <tr>
-                       <td><span>Test Label 7</span></td>
-               </tr>
-       </table>
-</div>
-
-<div id="inlineEnclosure-5"><span> <span>Test Label 8</span> </span></div>
-
-<div id="inlineEnclosure-6"><span>Test Label 9</span></div>
-
-<div id="customInlineEnclosureId"><span>Test Label 10</span>
-</div>
-
-
-</body>
-</html>
+<html>
+<body>
+
+<span id="inlineEnclosure-1"> <span>Test Label 1</span> </span>
+
+<div id="inlineEnclosure-2">
+       <table>
+               <tr>
+                       <td><span>Test Label 2</span></td>
+               </tr>
+       </table>
+</div>
+
+
+
+<div id="inlineEnclosure-4">
+       <table>
+               <tr>
+                       <td><span>Test Label 4</span></td>
+               </tr>
+       </table>
+       <table>
+               <tr>
+                       <td><span>Test Label 5</span></td>
+               </tr>
+       </table>
+       <table>
+               <tr>
+                       <td><span>Test Label 6</span></td>
+               </tr>
+       </table>
+       <table>
+               <tr>
+                       <td><span>Test Label 7</span></td>
+               </tr>
+       </table>
+</div>
+
+<div id="inlineEnclosure-5"><span> <span>Test Label 8</span> </span></div>
+
+<div id="inlineEnclosure-6"><span>Test Label 9</span></div>
+
+<div id="customInlineEnclosureId"><span>Test Label 10</span>
+</div>
+
+
+</body>
+</html>


Reply via email to