Author: jdonnerstag
Date: Mon Oct  5 19:35:59 2009
New Revision: 821982

URL: http://svn.apache.org/viewvc?rev=821982&view=rev
Log:
fixed:  Regression: "Could not find child with id: <ID> in the 
wicket:enclosure" for non-component tag
Issue: WICKET-2506

Added:
    
wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/internal/EnclosurePage_7.html
    
wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/internal/EnclosurePage_7.java
Modified:
    
wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/html/internal/Enclosure.java
    
wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/internal/EnclosureTest.java

Modified: 
wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/html/internal/Enclosure.java
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/html/internal/Enclosure.java?rev=821982&r1=821981&r2=821982&view=diff
==============================================================================
--- 
wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/html/internal/Enclosure.java
 (original)
+++ 
wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/html/internal/Enclosure.java
 Mon Oct  5 19:35:59 2009
@@ -180,22 +180,36 @@
                }
        }
 
+       /**
+        * 
+        * @param container
+        * @param markupStream
+        * @param enclosureOpenTag
+        */
        private void applyEnclosureVisibilityToChildren(final MarkupContainer 
container,
-               final MarkupStream markupStream, ComponentTag enclosureOpenTag)
+               final MarkupStream markupStream, final ComponentTag 
enclosureOpenTag)
        {
                DirectChildTagIterator it = new 
DirectChildTagIterator(markupStream, enclosureOpenTag);
                while (it.hasNext())
                {
                        final ComponentTag tag = it.next();
-                       final Component child = container.get(tag.getId());
-                       // record original visiblity allowed value, will 
restore later
-                       changes.put(child, child.isVisibilityAllowed());
-                       child.setVisibilityAllowed(isVisible());
+                       if (tag.isAutoComponentTag() == false)
+                       {
+                               final Component child = 
container.get(tag.getId());
+
+                               // record original visiblity allowed value, 
will restore later
+                               changes.put(child, child.isVisibilityAllowed());
+                               child.setVisibilityAllowed(isVisible());
+                       }
                }
                it.rewind();
        }
 
-       private void checkChildComponent(Component controller)
+       /**
+        * 
+        * @param controller
+        */
+       private void checkChildComponent(final Component controller)
        {
                if (controller == null)
                {
@@ -209,6 +223,12 @@
                }
        }
 
+       /**
+        * 
+        * @param container
+        * @param markupStream
+        * @param enclosureOpenTag
+        */
        private void ensureAllChildrenPresent(final MarkupContainer container,
                final MarkupStream markupStream, ComponentTag enclosureOpenTag)
        {
@@ -217,43 +237,50 @@
                {
                        final ComponentTag tag = it.next();
 
-                       Component child = container.get(tag.getId());
-                       if (child == null)
+                       if (tag.isAutoComponentTag() == false)
                        {
-                               // component does not yet exist in the 
container, attempt to resolve it using
-                               // resolvers
-                               final int tagIndex = it.getCurrentIndex();
-
-                               // because the resolvers can auto-add and 
therefore immediately render the component
-                               // we have to buffer the output since we do not 
yet know the visibility of the
-                               // enclosure
-                               CharSequence buffer = new 
ResponseBufferZone(getRequestCycle(), markupStream)
+                               Component child = container.get(tag.getId());
+                               if (child == null)
                                {
-                                       @Override
-                                       protected void 
executeInsideBufferedZone()
+                                       // component does not yet exist in the 
container, attempt to resolve it using
+                                       // resolvers
+                                       final int tagIndex = 
it.getCurrentIndex();
+
+                                       // because the resolvers can auto-add 
and therefore immediately render the
+                                       // component
+                                       // we have to buffer the output since 
we do not yet know the visibility of the
+                                       // enclosure
+                                       CharSequence buffer = new 
ResponseBufferZone(getRequestCycle(), markupStream)
                                        {
-                                               
markupStream.setCurrentIndex(tagIndex);
-                                               
ComponentResolvers.resolve(container, markupStream, tag);
-                                       }
-                               }.execute();
+                                               @Override
+                                               protected void 
executeInsideBufferedZone()
+                                               {
+                                                       
markupStream.setCurrentIndex(tagIndex);
+                                                       
ComponentResolvers.resolve(container, markupStream, tag);
+                                               }
+                                       }.execute();
 
-                               child = container.get(tag.getId());
-                               checkChildComponent(child);
+                                       child = container.get(tag.getId());
+                                       checkChildComponent(child);
 
-                               if (buffer.length() > 0)
-                               {
-                                       // we have already rendered this child 
component, insert a stub component that
-                                       // will dump the markup during the 
normal render process if the enclosure is
-                                       // visible
-                                       final Component stub = new 
AutoMarkupLabel(child.getId(), buffer);
-                                       container.replace(stub); // ok here 
because we are replacing auto with auto
+                                       if (buffer.length() > 0)
+                                       {
+                                               // we have already rendered 
this child component, insert a stub component
+                                               // that
+                                               // will dump the markup during 
the normal render process if the enclosure is
+                                               // visible
+                                               final Component stub = new 
AutoMarkupLabel(child.getId(), buffer);
+                                               container.replace(stub); // ok 
here because we are replacing auto with auto
+                                       }
                                }
                        }
                }
                it.rewind();
        }
 
-
+       /**
+        * @see org.apache.wicket.Component#onDetach()
+        */
        @Override
        protected void onDetach()
        {
@@ -261,6 +288,9 @@
                super.onDetach();
        }
 
+       /**
+        * 
+        */
        private void restoreOriginalChildVisibility()
        {
                if (changes != null)

Added: 
wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/internal/EnclosurePage_7.html
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/internal/EnclosurePage_7.html?rev=821982&view=auto
==============================================================================
--- 
wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/internal/EnclosurePage_7.html
 (added)
+++ 
wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/internal/EnclosurePage_7.html
 Mon Oct  5 19:35:59 2009
@@ -0,0 +1,14 @@
+<html>
+  <div wicket:id="group">
+    <table>
+      <wicket:enclosure child="radio">
+        <tr>
+          <td><input type="radio" wicket:id="radio" /> radio</td>
+        </tr>
+        <tr>
+          <td><a href="woops" class="linkhint">woops</a></td>
+        </tr>
+      </wicket:enclosure>
+    </table>
+  </div>
+</html>

Added: 
wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/internal/EnclosurePage_7.java
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/internal/EnclosurePage_7.java?rev=821982&view=auto
==============================================================================
--- 
wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/internal/EnclosurePage_7.java
 (added)
+++ 
wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/internal/EnclosurePage_7.java
 Mon Oct  5 19:35:59 2009
@@ -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.internal;
+
+import org.apache.wicket.markup.html.WebPage;
+import org.apache.wicket.markup.html.form.Radio;
+import org.apache.wicket.markup.html.form.RadioGroup;
+
+public class EnclosurePage_7 extends WebPage
+{
+       public EnclosurePage_7()
+       {
+               this.add(new RadioGroup("group").add(new Radio<Void>("radio")));
+       }
+}

Modified: 
wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/internal/EnclosureTest.java
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/internal/EnclosureTest.java?rev=821982&r1=821981&r2=821982&view=diff
==============================================================================
--- 
wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/internal/EnclosureTest.java
 (original)
+++ 
wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/internal/EnclosureTest.java
 Mon Oct  5 19:35:59 2009
@@ -136,4 +136,13 @@
                assertTrue(doc.contains("content1"));
                assertTrue(doc.contains("content2"));
        }
+
+       /**
+        * 
+        */
+       public void testRender()
+       {
+               tester = new WicketTester(EnclosurePage_7.class);
+               tester.startPage(EnclosurePage_7.class);
+       }
 }


Reply via email to