Author: ivaynberg
Date: Thu Jul 21 05:52:50 2011
New Revision: 1149042

URL: http://svn.apache.org/viewvc?rev=1149042&view=rev
Log:

Issue: WICKET-3903

Added:
    
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/markup/html/form/AutoLabelTextResolver.java
   (with props)
    
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/markup/html/internal/ResponseBufferZone.java
   (with props)
    
wicket/trunk/wicket-core/src/test/java/org/apache/wicket/markup/html/form/AutoFormLabelPickupTest$PickUpLabelPage.html
   (with props)
    
wicket/trunk/wicket-core/src/test/java/org/apache/wicket/markup/html/form/AutoFormLabelPickupTest$PickUpLabelPage.properties
   (with props)
    
wicket/trunk/wicket-core/src/test/java/org/apache/wicket/markup/html/form/AutoFormLabelPickupTest$PrintLabelPage.html
   (with props)
    
wicket/trunk/wicket-core/src/test/java/org/apache/wicket/markup/html/form/AutoFormLabelPickupTest$PrintLabelPage.properties
   (with props)
    
wicket/trunk/wicket-core/src/test/java/org/apache/wicket/markup/html/form/AutoFormLabelPickupTest.java
   (with props)
    
wicket/trunk/wicket-core/src/test/java/org/apache/wicket/markup/html/form/AutoLabelWithContentTest$LabelWithMessagePage.html
   (with props)
    
wicket/trunk/wicket-core/src/test/java/org/apache/wicket/markup/html/form/AutoLabelWithContentTest$LabelWithMessagePage.properties
   (with props)
    
wicket/trunk/wicket-core/src/test/java/org/apache/wicket/markup/html/form/AutoLabelWithContentTest$LabelWithNestedComponentsPage.html
   (with props)
    
wicket/trunk/wicket-core/src/test/java/org/apache/wicket/markup/html/form/AutoLabelWithContentTest.java
   (with props)
    
wicket/trunk/wicket-core/src/test/java/org/apache/wicket/markup/html/form/AutoLabelWithinEnclosureTest$LabelWithinEnclosurePage.html
   (with props)
    
wicket/trunk/wicket-core/src/test/java/org/apache/wicket/markup/html/form/AutoLabelWithinEnclosureTest.java
   (with props)
Modified:
    
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/markup/html/form/AutoLabelResolver.java
    
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/markup/html/form/AutoLabelTagHandler.java
    
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/markup/parser/filter/EnclosureHandler.java
    
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/protocol/http/WebApplication.java
    
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/util/tester/BaseWicketTester.java
    
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/util/tester/WicketTester.java
    
wicket/trunk/wicket-core/src/test/java/org/apache/wicket/markup/html/form/AutoLabelTest.java

Modified: 
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/markup/html/form/AutoLabelResolver.java
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket-core/src/main/java/org/apache/wicket/markup/html/form/AutoLabelResolver.java?rev=1149042&r1=1149041&r2=1149042&view=diff
==============================================================================
--- 
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/markup/html/form/AutoLabelResolver.java
 (original)
+++ 
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/markup/html/form/AutoLabelResolver.java
 Thu Jul 21 05:52:50 2011
@@ -21,14 +21,8 @@ import org.apache.wicket.MarkupContainer
 import org.apache.wicket.WicketRuntimeException;
 import org.apache.wicket.markup.ComponentTag;
 import org.apache.wicket.markup.MarkupStream;
-import org.apache.wicket.markup.RawMarkup;
-import org.apache.wicket.markup.html.WebMarkupContainer;
-import org.apache.wicket.markup.parser.XmlPullParser;
-import org.apache.wicket.markup.parser.XmlTag;
+import org.apache.wicket.markup.html.TransparentWebMarkupContainer;
 import org.apache.wicket.markup.resolver.IComponentResolver;
-import org.apache.wicket.model.Model;
-import org.apache.wicket.util.string.AppendingStringBuffer;
-import org.apache.wicket.util.string.Strings;
 import org.apache.wicket.util.visit.IVisit;
 import org.apache.wicket.util.visit.IVisitor;
 import org.slf4j.Logger;
@@ -45,13 +39,8 @@ import org.slf4j.LoggerFactory;
  * component is required</li>
  * <li>Appends {@code error} css class to the {@code <label>} tag if the 
referenced form component
  * has failed validation</li>
- * <li>If the {@code <label>} tag contains {@code <span 
class='label-text'></span>} markup and the
- * form component has a label configured either via the label model or a 
property files, the body of
- * the {code <span>} will be replaced with the label</li>
- * <li>If the {@code <label>} tag contains {@code <span 
class='label-text'>body</span>} markup and
- * the form component does not have a label configured either via the label 
model or a properties
- * file, the label of the form component will be set to the body of the {@code 
<span>} tag - in this
- * example {@code body}</li>
+ * <li>Appends {@code disabled} css class to the {@code <label>} tag if the 
referenced form
+ * component has is not enabled in hierarchy</li>
  * </ul>
  * 
  * <p>
@@ -64,23 +53,8 @@ import org.slf4j.LoggerFactory;
  * searched from the closest parent to the page.
  * </p>
  * 
- * <p>
- * Given markup like this:
- * 
- * <code>
- * [label wicket:for="name"][span 
class="label-text"]Name[/span]:[/label][input wicket:id="name" type="text"/]
- * </code>
- * 
- * If the {@code name} component has its label set to 'First Name' the 
resulting output will be:
- * <code>
- * [label for="name5"][span class="label-text"]First 
Name[/span]:[/label][input name="name" type="text" id="name5"/]
- * </code>
- * 
- * However, if the {@code name} component does not have a label set then it 
will be set to
- * {@code Name} based on the markup.
- * </p>
- * 
  * @author igor
+ * @author Carl-Eric Menzel <[email protected]>
  */
 public class AutoLabelResolver implements IComponentResolver
 {
@@ -133,7 +107,7 @@ public class AutoLabelResolver implement
         * @param id
         * @return Component
         */
-       protected Component findRelatedComponent(MarkupContainer container, 
final String id)
+       static Component findRelatedComponent(MarkupContainer container, final 
String id)
        {
                // try the quick and easy route first
 
@@ -186,7 +160,7 @@ public class AutoLabelResolver implement
         * 
         * @author igor
         */
-       protected static class AutoLabel extends WebMarkupContainer
+       protected static class AutoLabel extends TransparentWebMarkupContainer
        {
                private static final long serialVersionUID = 1L;
 
@@ -215,199 +189,20 @@ public class AutoLabelResolver implement
                                {
                                        tag.append("class", "error", " ");
                                }
-                       }
-               }
-
-               @Override
-               public void onComponentTagBody(MarkupStream markupStream, 
ComponentTag openTag)
-               {
-                       if (!(markupStream.get() instanceof RawMarkup))
-                       {
-                               // no raw markup found inside the label, do not 
modify the contents
-                               return;
-                       }
-
-                       // read all raw markup in the body and find the range 
of the label text inside it. the
-                       // range is specified as the body of the <span 
class='text'></span> tag.
-
-                       AppendingStringBuffer markup = 
readBodyMarkup(markupStream);
-                       int[] range = findLabelTextRange(markup);
-                       final int start = range[0];
-                       final int end = range[1];
-
-                       if (start < 0)
-                       {
-                               // if we could not find the range of the label 
text in the markup we have nothing
-                               // further to do
-
-                               super.onComponentTagBody(markupStream, openTag);
-                               return;
-                       }
-
-                       // based on whether or not the form component has a 
label set read or write it into the
-                       // markup
-
-                       String label = getLabelText();
-
-                       if (label != null)
-                       {
-                               // if label is set write it into the markup
-
-                               markup = markup.replace(start, end, label);
-                               replaceComponentTagBody(markupStream, openTag, 
markup);
-                       }
-                       else
-                       {
-                               // if label is not set, read it from the markup 
into the form component
-
-                               if (component instanceof FormComponent)
+                               if (!fc.isEnabledInHierarchy())
                                {
-                                       FormComponent<?> fc = 
(FormComponent<?>)component;
-                                       String markupLabel = 
markup.substring(start, end);
-                                       fc.setLabel(Model.of(markupLabel));
-                                       super.onComponentTagBody(markupStream, 
openTag);
+                                       tag.append("class", "disabled", " ");
                                }
                        }
                }
 
+
                /**
-                * Finds start and end index of text in the label. This range 
is represented by the body of
-                * the {@code <span class='text'></span>} tag
-                * 
-                * @param markup
-                * @return start und end index of text in the label
+                * @return the component this label points to, if any.
                 */
-               protected int[] findLabelTextRange(AppendingStringBuffer markup)
-               {
-                       int[] range = new int[] { -1, -1 };
-
-                       XmlPullParser parser = new XmlPullParser();
-                       XmlTag opening = null; // opening label text span tag
-                       XmlTag closing = null; // close label text span tag
-
-                       try
-                       {
-                               parser.parse(markup);
-
-                               XmlTag tag = null; // current tag
-
-                               int depth = 0; // depth of span tags
-                               int openDepth = -1; // depth of the label text 
open span tag
-
-                               while (((tag = parser.nextTag()) != null))
-                               {
-                                       if 
(!"span".equalsIgnoreCase(tag.getName()) || tag.getNamespace() != null)
-                                       {
-                                               // skip non-span tags
-                                               continue;
-                                       }
-
-                                       if (opening != null && tag.isClose() && 
depth == openDepth)
-                                       {
-                                               // found the closing tag we 
need, we are done
-                                               closing = tag;
-                                               break;
-                                       }
-
-                                       depth += tag.isOpen() ? 1 : -1;
-
-                                       if (opening == null && isTextSpan(tag))
-                                       {
-                                               // found the opening tag, keep 
looking for the closing one
-                                               opening = tag;
-                                               openDepth = depth;
-                                               continue;
-                                       }
-                               }
-                       }
-                       catch (Exception e)
-                       {
-                               throw new WicketRuntimeException(
-                                       "Could not parse markup while 
processing an auto label for component: " +
-                                               component.toString(false), e);
-                       }
-
-                       if (opening != null)
-                       {
-                               // calculate the range of the tag's body, this 
is where the label text is/will be
-                               range[0] = opening.getPos() + 
opening.getLength();
-                               range[1] = closing.getPos();
-                       }
-
-                       return range;
-               }
-
-               protected AppendingStringBuffer readBodyMarkup(MarkupStream 
markupStream)
-               {
-                       int streamIndex = markupStream.getCurrentIndex();
-
-                       AppendingStringBuffer markup = new 
AppendingStringBuffer();
-                       do
-                       {
-                               
markup.append(((RawMarkup)markupStream.get()).toString());
-                               markupStream.next();
-                       }
-                       while ((markupStream.get() instanceof RawMarkup));
-
-                       markupStream.setCurrentIndex(streamIndex);
-
-                       return markup;
-               }
-
-               protected String getLabelText()
-               {
-                       String label = null;
-                       if (component instanceof ILabelProvider)
-                       {
-                               ILabelProvider<?> provider = 
(ILabelProvider<?>)component;
-                               if (provider.getLabel() != null)
-                               {
-                                       Object value = 
provider.getLabel().getObject();
-                                       if (value != null)
-                                       {
-                                               label = value.toString();
-                                       }
-                               }
-                       }
-
-                       if (label == null && component instanceof FormComponent)
-                       {
-                               label = 
((FormComponent<?>)component).getDefaultLabel("wicket:unknown");
-                               if ("wicket:unknown".equals(label))
-                               {
-                                       label = null;
-                               }
-                       }
-                       return label;
-               }
-
-               protected final boolean isTextSpan(XmlTag tag)
+               public Component getRelatedComponent()
                {
-                       if (!tag.isOpen())
-                               return false;
-
-                       if (!"span".equalsIgnoreCase(tag.getName()) || 
tag.getNamespace() != null)
-                               return false;
-
-                       String classNames = 
tag.getAttributes().getString("class");
-                       if (Strings.isEmpty(classNames))
-                               return false;
-
-                       boolean textClassFound = false;
-                       for (String className : classNames.split(" "))
-                       {
-                               if ("label-text".equals(className))
-                               {
-                                       textClassFound = true;
-                                       break;
-                               }
-                       }
-                       if (!textClassFound)
-                               return false;
-
-
-                       return true;
+                       return component;
                }
-
        }
 }

Modified: 
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/markup/html/form/AutoLabelTagHandler.java
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket-core/src/main/java/org/apache/wicket/markup/html/form/AutoLabelTagHandler.java?rev=1149042&r1=1149041&r2=1149042&view=diff
==============================================================================
--- 
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/markup/html/form/AutoLabelTagHandler.java
 (original)
+++ 
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/markup/html/form/AutoLabelTagHandler.java
 Thu Jul 21 05:52:50 2011
@@ -66,6 +66,7 @@ public class AutoLabelTagHandler extends
 
                tag.setId(getClass().getName());
                tag.setModified(true);
+               tag.setAutoComponentTag(true);
                return tag;
        }
 }

Added: 
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/markup/html/form/AutoLabelTextResolver.java
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket-core/src/main/java/org/apache/wicket/markup/html/form/AutoLabelTextResolver.java?rev=1149042&view=auto
==============================================================================
--- 
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/markup/html/form/AutoLabelTextResolver.java
 (added)
+++ 
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/markup/html/form/AutoLabelTextResolver.java
 Thu Jul 21 05:52:50 2011
@@ -0,0 +1,250 @@
+/*
+ * 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.form;
+
+import org.apache.wicket.Component;
+import org.apache.wicket.MarkupContainer;
+import org.apache.wicket.markup.ComponentTag;
+import org.apache.wicket.markup.MarkupStream;
+import org.apache.wicket.markup.WicketTag;
+import org.apache.wicket.markup.html.WebMarkupContainer;
+import org.apache.wicket.markup.html.basic.Label;
+import org.apache.wicket.markup.html.form.AutoLabelResolver.AutoLabel;
+import org.apache.wicket.markup.html.internal.ResponseBufferZone;
+import org.apache.wicket.markup.parser.XmlTag;
+import org.apache.wicket.markup.parser.filter.WicketTagIdentifier;
+import org.apache.wicket.markup.resolver.IComponentResolver;
+import org.apache.wicket.model.Model;
+import org.apache.wicket.request.cycle.RequestCycle;
+import org.apache.wicket.util.string.Strings;
+
+/**
+ * Resolver that provides the <code>{@literal <wicket:label>}</code> tag, 
which will output a
+ * FormComponent's {@link FormComponent#getLabel() label} without requiring a 
manual extra component
+ * such as {@link Label} or {@link FormComponentLabel}.
+ * 
+ * <code>{@literal <wicket:label>}</code> can be used
+ * <ul>
+ * <li>together with <code>{@literal <label wicket:for="...">}</code>:
+ * 
+ * <pre>
+ * {@literal
+ * <label wicket:for="myFormComponent">some other markup, 
optionally<wicket:label/></label>
+ * }
+ * </pre>
+ * 
+ * </li>
+ * <li>
+ * standalone, with a <code>for</code> attribute:
+ * 
+ * <pre>
+ * {@literal
+ * <wicket:label for="myFormComponent"/>
+ * }
+ * </pre>
+ * 
+ * </li>
+ * </ul>
+ * <p>
+ * It also supports both input and output:
+ * <ul>
+ * <li>If the FormComponent has a label model, the <code>{@literal 
<wicket:label>}</code> tag will
+ * be replaced by the contents of that label.</li>
+ * <li>If the FormComponent's label model is null, it can be picked up from
+ * <code>{@literal <wicket:label>}</code>:
+ * <ul>
+ * <li><code>{@literal <wicket:label>}</code> can contain some raw markup, 
like this:
+ * 
+ * <pre>
+ * {@literal
+ * <wicket:label>I will become the component's label!</wicket:label>
+ * }
+ * </pre>
+ * 
+ * </li>
+ * <li>Or it can be a message pulled from resources, similar to
+ * <code>{@literal <wicket:message/>}</code>:
+ * 
+ * <pre>
+ * {@literal
+ * <wicket:label key="messagekey"/>
+ * }
+ * </pre>
+ * 
+ * </li>
+ * </ul>
+ * </li>
+ * </ul>
+ * 
+ * 
+ * @author Carl-Eric Menzel <[email protected]>
+ * @author igor
+ */
+public class AutoLabelTextResolver implements IComponentResolver
+{
+       static
+       {
+               WicketTagIdentifier.registerWellKnownTagName("label");
+       }
+
+       /**
+        * This is inserted by the resolver to render the label.
+        */
+       private static class TextLabel extends WebMarkupContainer
+       {
+
+               private final Component labeled;
+
+               public TextLabel(String id, Component labeled)
+
+               {
+                       super(id);
+                       this.labeled = labeled;
+                       setRenderBodyOnly(true);
+               }
+
+               @Override
+               protected void onComponentTag(final ComponentTag tag)
+               {
+                       if (tag.isOpenClose())
+                       {
+                               tag.setType(XmlTag.TagType.OPEN);
+                       }
+                       super.onComponentTag(tag);
+               }
+
+               @Override
+               public void onComponentTagBody(final MarkupStream markupStream, 
final ComponentTag openTag)
+               {
+                       boolean storeLabelText = false;
+
+                       // try and find some form of label content...
+                       String labelText = null;
+
+                       // check if the labeled component is a label provider
+
+                       if (labeled instanceof ILabelProvider)
+                       {
+                               ILabelProvider<String> provider = 
(ILabelProvider<String>)labeled;
+                               if (provider.getLabel() != null)
+                               {
+                                       String text = 
provider.getLabel().getObject();
+                                       if (!Strings.isEmpty(text))
+                                       {
+                                               labelText = text;
+                                       }
+                               }
+                       }
+
+                       // check if the labeled component is a form component
+
+                       if (labelText == null && labeled instanceof 
FormComponent)
+                       {
+                               String text = 
((FormComponent<?>)labeled).getDefaultLabel("wicket:unknown");
+                               if (!"wicket:unknown".equals(text) && 
!Strings.isEmpty(text))
+                               {
+                                       labelText = text;
+                               }
+                       }
+
+                       // check if wicket:label tag has a message key
+                       if (labelText == null && openTag.getAttribute("key") != 
null)
+                       {
+                               String text = 
labeled.getString(openTag.getAttribute("key"));
+                               if (!Strings.isEmpty(text))
+                               {
+                                       labelText = text;
+                                       storeLabelText = true;
+                               }
+                       }
+
+                       // as last resort use the tag body
+                       if (labelText == null)
+                       {
+                               String text = new 
ResponseBufferZone(RequestCycle.get(), markupStream)
+                               {
+                                       @Override
+                                       protected void 
executeInsideBufferedZone()
+                                       {
+                                               
TextLabel.super.onComponentTagBody(markupStream, openTag);
+                                       }
+                               }.execute().toString();
+
+                               if (!Strings.isEmpty(text))
+                               {
+                                       labelText = text;
+                                       storeLabelText = true;
+                               }
+                       }
+
+                       // print the label text
+                       replaceComponentTagBody(markupStream, openTag, 
labelText);
+
+                       // store the label text in FormComponent's label model 
so its available to errors
+                       if (labeled instanceof FormComponent)
+                       {
+                               FormComponent<?> fc = (FormComponent<?>)labeled;
+                               fc.setLabel(Model.of(labelText));
+                       }
+               }
+       }
+
+       public Component resolve(MarkupContainer container, MarkupStream 
markupStream, ComponentTag tag)
+       {
+               if (tag instanceof WicketTag && 
"label".equals(((WicketTag)tag).getName()))
+               {
+                       // We need to find a FormComponent...
+                       Component related = null;
+                       // ...which could be explicitly specified...
+                       if (tag.getAttribute("for") != null)
+                       {
+                               Component component = 
AutoLabelResolver.findRelatedComponent(container,
+                                       tag.getAttribute("for"));
+                               related = component;
+                       }
+                       if (related == null)
+                       {
+                               // ...or available through an AutoLabel, either 
directly above us...
+                               if (container instanceof AutoLabel)
+                               {
+                                       related = 
((AutoLabel)container).getRelatedComponent();
+                               }
+                               if (related == null)
+                               {
+                                       // ...or perhaps further up...
+                                       AutoLabel autoLabel = 
container.findParent(AutoLabel.class);
+                                       if (autoLabel != null)
+                                       {
+                                               related = 
autoLabel.getRelatedComponent();
+                                       }
+                               }
+                       }
+                       if (related == null)
+                       {
+                               // ...or it might just not be available.
+                               throw new IllegalStateException("no related 
component found for <wicket:label>");
+                       }
+                       else
+                       {
+                               // ...found the form component, so we can 
return our label.
+                               return new TextLabel("label" + 
container.getPage().getAutoIndex(), related);
+                       }
+               }
+               return null;
+       }
+
+}

Propchange: 
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/markup/html/form/AutoLabelTextResolver.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: 
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/markup/html/internal/ResponseBufferZone.java
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket-core/src/main/java/org/apache/wicket/markup/html/internal/ResponseBufferZone.java?rev=1149042&view=auto
==============================================================================
--- 
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/markup/html/internal/ResponseBufferZone.java
 (added)
+++ 
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/markup/html/internal/ResponseBufferZone.java
 Thu Jul 21 05:52:50 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.MarkupStream;
+import org.apache.wicket.request.Response;
+import org.apache.wicket.request.cycle.RequestCycle;
+import org.apache.wicket.response.StringResponse;
+
+/**
+ * Utility class that buffers output and maintains markup stream index
+ * 
+ * @author igor.vaynberg
+ */
+public abstract class ResponseBufferZone
+{
+       private final RequestCycle cycle;
+       private final MarkupStream stream;
+
+       public ResponseBufferZone(RequestCycle cycle, MarkupStream stream)
+       {
+               this.cycle = cycle;
+               this.stream = stream;
+       }
+
+       public CharSequence execute()
+       {
+               final int originalStreamPos = stream.getCurrentIndex();
+
+               final Response original = cycle.getResponse();
+
+               final StringResponse buffer = new StringResponse();
+               cycle.setResponse(buffer);
+               try
+               {
+                       executeInsideBufferedZone();
+                       return buffer.getBuffer();
+               }
+               finally
+               {
+                       cycle.setResponse(original);
+                       stream.setCurrentIndex(originalStreamPos);
+               }
+       }
+
+       protected abstract void executeInsideBufferedZone();
+}

Propchange: 
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/markup/html/internal/ResponseBufferZone.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: 
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/markup/parser/filter/EnclosureHandler.java
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket-core/src/main/java/org/apache/wicket/markup/parser/filter/EnclosureHandler.java?rev=1149042&r1=1149041&r2=1149042&view=diff
==============================================================================
--- 
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/markup/parser/filter/EnclosureHandler.java
 (original)
+++ 
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/markup/parser/filter/EnclosureHandler.java
 Thu Jul 21 05:52:50 2011
@@ -125,7 +125,8 @@ public final class EnclosureHandler exte
                        }
                }
                // Are we inside a wicket:enclosure tag?
-               else if ((tag.getId() != null) && (isWicketTag == false) && 
(stack != null))
+               else if ((tag.getId() != null) && (isWicketTag == false) && 
(stack != null) &&
+                       (!tag.isAutoComponentTag()))
                {
                        ComponentTag lastEnclosure = stack.lastElement();
 

Modified: 
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/protocol/http/WebApplication.java
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket-core/src/main/java/org/apache/wicket/protocol/http/WebApplication.java?rev=1149042&r1=1149041&r2=1149042&view=diff
==============================================================================
--- 
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/protocol/http/WebApplication.java
 (original)
+++ 
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/protocol/http/WebApplication.java
 Thu Jul 21 05:52:50 2011
@@ -34,6 +34,7 @@ import org.apache.wicket.ajax.AjaxReques
 import org.apache.wicket.markup.MarkupType;
 import org.apache.wicket.markup.html.WebPage;
 import org.apache.wicket.markup.html.form.AutoLabelResolver;
+import org.apache.wicket.markup.html.form.AutoLabelTextResolver;
 import org.apache.wicket.markup.html.pages.AccessDeniedPage;
 import org.apache.wicket.markup.html.pages.InternalErrorPage;
 import org.apache.wicket.markup.html.pages.PageExpiredErrorPage;
@@ -585,6 +586,7 @@ public abstract class WebApplication ext
                // Add resolver for automatically resolving HTML links
                getPageSettings().addComponentResolver(new AutoLinkResolver());
                getPageSettings().addComponentResolver(new AutoLabelResolver());
+               getPageSettings().addComponentResolver(new 
AutoLabelTextResolver());
 
                // Set resource finder to web app path
                getResourceSettings().setResourceFinder(getResourceFinder());

Modified: 
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/util/tester/BaseWicketTester.java
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket-core/src/main/java/org/apache/wicket/util/tester/BaseWicketTester.java?rev=1149042&r1=1149041&r2=1149042&view=diff
==============================================================================
--- 
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/util/tester/BaseWicketTester.java
 (original)
+++ 
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/util/tester/BaseWicketTester.java
 Thu Jul 21 05:52:50 2011
@@ -16,8 +16,7 @@
  */
 package org.apache.wicket.util.tester;
 
-import static junit.framework.Assert.assertNotNull;
-import static junit.framework.Assert.fail;
+import static junit.framework.Assert.*;
 
 import java.io.IOException;
 import java.io.Serializable;
@@ -352,7 +351,7 @@ public class BaseWicketTester
        }
 
        /**
-        * 
+        *
         */
        private void setupNextRequestCycle()
        {
@@ -404,7 +403,7 @@ public class BaseWicketTester
        }
 
        /**
-        * 
+        *
         */
        private void newSession()
        {
@@ -680,7 +679,7 @@ public class BaseWicketTester
        }
 
        /**
-        * 
+        *
         */
        private void recordRequestResponse()
        {
@@ -1593,6 +1592,19 @@ public class BaseWicketTester
        }
 
        /**
+        * assert the content of last rendered page contains(matches) regex 
pattern.
+        * 
+        * @param pattern
+        *            reqex pattern to match
+        * @return a <code>Result</code>
+        */
+       public Result ifContainsNot(String pattern)
+       {
+               return isFalse("pattern '" + pattern + "' found",
+                       getLastResponseAsString().matches("(?s).*" + pattern + 
".*"));
+       }
+
+       /**
         * assert the model of {@link ListView} use expectedList
         * 
         * @param path
@@ -2439,7 +2451,7 @@ public class BaseWicketTester
        }
 
        /**
-        * 
+        *
         */
        private class LastPageRecordingPageRendererProvider implements 
IPageRendererProvider
        {
@@ -2467,7 +2479,7 @@ public class BaseWicketTester
        }
 
        /**
-        * 
+        *
         */
        private class TestExceptionMapper implements IExceptionMapper
        {
@@ -2499,7 +2511,7 @@ public class BaseWicketTester
        }
 
        /**
-        * 
+        *
         */
        private class TestRequestCycleProvider implements IRequestCycleProvider
        {
@@ -2520,7 +2532,7 @@ public class BaseWicketTester
        }
 
        /**
-        * 
+        *
         */
        private class TestRequestMapper implements IRequestMapper
        {
@@ -2557,11 +2569,11 @@ public class BaseWicketTester
        }
 
        /**
-        * 
+        *
         */
 
        /**
-        * 
+        *
         */
        private static class TestPageManagerProvider implements 
IPageManagerProvider
        {
@@ -2572,7 +2584,7 @@ public class BaseWicketTester
        }
 
        /**
-        * 
+        *
         */
        private class TestFilterConfig implements FilterConfig
        {
@@ -2605,7 +2617,7 @@ public class BaseWicketTester
        }
 
        /**
-        * 
+        *
         */
        private static class WicketTesterServletWebResponse extends 
ServletWebResponse
                implements

Modified: 
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/util/tester/WicketTester.java
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket-core/src/main/java/org/apache/wicket/util/tester/WicketTester.java?rev=1149042&r1=1149041&r2=1149042&view=diff
==============================================================================
--- 
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/util/tester/WicketTester.java
 (original)
+++ 
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/util/tester/WicketTester.java
 Thu Jul 21 05:52:50 2011
@@ -16,10 +16,7 @@
  */
 package org.apache.wicket.util.tester;
 
-import static junit.framework.Assert.assertEquals;
-import static junit.framework.Assert.assertNotNull;
-import static junit.framework.Assert.assertTrue;
-import static junit.framework.Assert.fail;
+import static junit.framework.Assert.*;
 
 import java.io.Serializable;
 import java.util.ArrayList;
@@ -307,6 +304,17 @@ public class WicketTester extends BaseWi
        }
 
        /**
+        * The opposite of {@link #assertContains(String)}.
+        * 
+        * @param pattern
+        *            pattern
+        */
+       public void assertContainsNot(String pattern)
+       {
+               assertResult(ifContainsNot(pattern));
+       }
+
+       /**
         * Asserts error-level feedback messages.
         * 
         * @param expectedErrorMessages

Added: 
wicket/trunk/wicket-core/src/test/java/org/apache/wicket/markup/html/form/AutoFormLabelPickupTest$PickUpLabelPage.html
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket-core/src/test/java/org/apache/wicket/markup/html/form/AutoFormLabelPickupTest%24PickUpLabelPage.html?rev=1149042&view=auto
==============================================================================
--- 
wicket/trunk/wicket-core/src/test/java/org/apache/wicket/markup/html/form/AutoFormLabelPickupTest$PickUpLabelPage.html
 (added)
+++ 
wicket/trunk/wicket-core/src/test/java/org/apache/wicket/markup/html/form/AutoFormLabelPickupTest$PickUpLabelPage.html
 Thu Jul 21 05:52:50 2011
@@ -0,0 +1,12 @@
+<html>
+<body>
+    <form wicket:id="form">
+        <label wicket:for="inputMarkupLabel"><wicket:label>label from 
markup</wicket:label></label>
+        <input type="text" wicket:id="inputMarkupLabel"/>
+        <label wicket:for="inputPropertiesLabel"><wicket:label key="msg">label 
from markup</wicket:label></label>
+        <input type="text" wicket:id="inputPropertiesLabel"/>
+        <label><wicket:label for="inputWithoutAutolabel">label from markup 
without autolabel</wicket:label></label>
+        <input type="text" wicket:id="inputWithoutAutolabel"/>
+    </form>
+</body>
+</html>

Propchange: 
wicket/trunk/wicket-core/src/test/java/org/apache/wicket/markup/html/form/AutoFormLabelPickupTest$PickUpLabelPage.html
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: 
wicket/trunk/wicket-core/src/test/java/org/apache/wicket/markup/html/form/AutoFormLabelPickupTest$PickUpLabelPage.properties
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket-core/src/test/java/org/apache/wicket/markup/html/form/AutoFormLabelPickupTest%24PickUpLabelPage.properties?rev=1149042&view=auto
==============================================================================
--- 
wicket/trunk/wicket-core/src/test/java/org/apache/wicket/markup/html/form/AutoFormLabelPickupTest$PickUpLabelPage.properties
 (added)
+++ 
wicket/trunk/wicket-core/src/test/java/org/apache/wicket/markup/html/form/AutoFormLabelPickupTest$PickUpLabelPage.properties
 Thu Jul 21 05:52:50 2011
@@ -0,0 +1 @@
+msg=label from properties

Propchange: 
wicket/trunk/wicket-core/src/test/java/org/apache/wicket/markup/html/form/AutoFormLabelPickupTest$PickUpLabelPage.properties
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: 
wicket/trunk/wicket-core/src/test/java/org/apache/wicket/markup/html/form/AutoFormLabelPickupTest$PrintLabelPage.html
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket-core/src/test/java/org/apache/wicket/markup/html/form/AutoFormLabelPickupTest%24PrintLabelPage.html?rev=1149042&view=auto
==============================================================================
--- 
wicket/trunk/wicket-core/src/test/java/org/apache/wicket/markup/html/form/AutoFormLabelPickupTest$PrintLabelPage.html
 (added)
+++ 
wicket/trunk/wicket-core/src/test/java/org/apache/wicket/markup/html/form/AutoFormLabelPickupTest$PrintLabelPage.html
 Thu Jul 21 05:52:50 2011
@@ -0,0 +1,8 @@
+<html>
+<body>
+    <form wicket:id="form">
+        <label wicket:for="input">|<wicket:label key="msg"/>|</label>
+        <input type="text" wicket:id="input"/>
+    </form>
+</body>
+</html>

Propchange: 
wicket/trunk/wicket-core/src/test/java/org/apache/wicket/markup/html/form/AutoFormLabelPickupTest$PrintLabelPage.html
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: 
wicket/trunk/wicket-core/src/test/java/org/apache/wicket/markup/html/form/AutoFormLabelPickupTest$PrintLabelPage.properties
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket-core/src/test/java/org/apache/wicket/markup/html/form/AutoFormLabelPickupTest%24PrintLabelPage.properties?rev=1149042&view=auto
==============================================================================
--- 
wicket/trunk/wicket-core/src/test/java/org/apache/wicket/markup/html/form/AutoFormLabelPickupTest$PrintLabelPage.properties
 (added)
+++ 
wicket/trunk/wicket-core/src/test/java/org/apache/wicket/markup/html/form/AutoFormLabelPickupTest$PrintLabelPage.properties
 Thu Jul 21 05:52:50 2011
@@ -0,0 +1 @@
+msg=label from properties

Propchange: 
wicket/trunk/wicket-core/src/test/java/org/apache/wicket/markup/html/form/AutoFormLabelPickupTest$PrintLabelPage.properties
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: 
wicket/trunk/wicket-core/src/test/java/org/apache/wicket/markup/html/form/AutoFormLabelPickupTest.java
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket-core/src/test/java/org/apache/wicket/markup/html/form/AutoFormLabelPickupTest.java?rev=1149042&view=auto
==============================================================================
--- 
wicket/trunk/wicket-core/src/test/java/org/apache/wicket/markup/html/form/AutoFormLabelPickupTest.java
 (added)
+++ 
wicket/trunk/wicket-core/src/test/java/org/apache/wicket/markup/html/form/AutoFormLabelPickupTest.java
 Thu Jul 21 05:52:50 2011
@@ -0,0 +1,94 @@
+/*
+ * 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.form;
+
+import org.apache.wicket.WicketTestCase;
+import org.apache.wicket.markup.html.WebPage;
+import org.apache.wicket.model.IModel;
+import org.apache.wicket.model.Model;
+import org.apache.wicket.util.tester.WicketTester;
+
+@SuppressWarnings({ "rawtypes", "serial", "unchecked" })
+public class AutoFormLabelPickupTest extends WicketTestCase
+{
+       public static class PrintLabelPage extends WebPage
+       {
+               public PrintLabelPage(IModel labelModel)
+               {
+                       Form form = new Form("form");
+                       add(form);
+                       form.add(new TextField("input", 
Model.of("")).setLabel(labelModel));
+               }
+       }
+       public static class PickUpLabelPage extends WebPage
+       {
+               public PickUpLabelPage(IModel labelModel)
+               {
+                       Form form = new Form("form");
+                       add(form);
+                       form.add(new TextField("inputMarkupLabel", 
Model.of("")).setLabel(labelModel));
+                       form.add(new TextField("inputPropertiesLabel", 
Model.of("")).setLabel(labelModel));
+                       form.add(new TextField("inputWithoutAutolabel", 
Model.of("")).setLabel(labelModel));
+               }
+       }
+
+
+       public void testLabelIsPrintedFromModel() throws Exception
+       {
+               WicketTester tester = new WicketTester();
+               tester.startPage(new PrintLabelPage(Model.of("label from 
model")));
+               tester.assertContains("<label wicket:for=\"input\" 
for=\"input2\">\\|label from model\\|</label>");
+       }
+
+       public void testLabelIsPrintedFromProperties() throws Exception
+       {
+               WicketTester tester = new WicketTester();
+               tester.startPage(new PrintLabelPage(Model.of((String)null)));
+               tester.assertContains("<label wicket:for=\"input\" 
for=\"input2\">\\|label from properties\\|</label>");
+       }
+
+       public void testLabelIsPickedUpFromMarkup() throws Exception
+       {
+               WicketTester tester = new WicketTester();
+               tester.startPage(new PickUpLabelPage(null));
+               assertEquals(
+                       "label from markup",
+                       
((FormComponent)tester.getComponentFromLastRenderedPage("form:inputMarkupLabel")).getLabel()
+                               .getObject());
+       }
+
+       public void testLabelIsPickedUpFromProperties() throws Exception
+       {
+               WicketTester tester = new WicketTester();
+               tester.startPage(new PickUpLabelPage(null));
+               assertEquals(
+                       "label from properties",
+                       
((FormComponent)tester.getComponentFromLastRenderedPage("form:inputPropertiesLabel")).getLabel()
+                               .getObject());
+       }
+
+       public void testWithoutAutolabel() throws Exception
+       {
+               WicketTester tester = new WicketTester();
+               tester.startPage(new PickUpLabelPage(null));
+               tester.assertContains("<label>label from markup without 
autolabel</label>");
+               assertEquals(
+                       "label from markup without autolabel",
+                       
((FormComponent)tester.getComponentFromLastRenderedPage("form:inputWithoutAutolabel")).getLabel()
+                               .getObject());
+       }
+}

Propchange: 
wicket/trunk/wicket-core/src/test/java/org/apache/wicket/markup/html/form/AutoFormLabelPickupTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: 
wicket/trunk/wicket-core/src/test/java/org/apache/wicket/markup/html/form/AutoLabelTest.java
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket-core/src/test/java/org/apache/wicket/markup/html/form/AutoLabelTest.java?rev=1149042&r1=1149041&r2=1149042&view=diff
==============================================================================
--- 
wicket/trunk/wicket-core/src/test/java/org/apache/wicket/markup/html/form/AutoLabelTest.java
 (original)
+++ 
wicket/trunk/wicket-core/src/test/java/org/apache/wicket/markup/html/form/AutoLabelTest.java
 Thu Jul 21 05:52:50 2011
@@ -45,22 +45,15 @@ public class AutoLabelTest extends Wicke
                }
 
                // simple insertion
-               assertRendered(new MyTestPage("<span 
class='label-text'>text</span>"),
-                       "<span class='label-text'>t</span>");
+               assertRendered(new 
MyTestPage("<wicket:label>text</wicket:label>"), ">t</label>");
 
                // preserves markup before and after
-               assertRendered(new MyTestPage(" <div> a </div> <span 
class='label-text'>text</span> b "),
-                       " <div> a </div> <span class='label-text'>t</span> b ");
+               assertRendered(new MyTestPage(" <div> a </div> 
<wicket:label>text</wicket:label> b "),
+                       " <div> a </div> t b ");
 
                // embedded span tags
-               assertRendered(
-                       new MyTestPage(" a <div> b <span 
class='label-text'>text</span> c </div> d"),
-                       " a <div> b <span class='label-text'>t</span> c </div> 
d");
-
-               // double text span tags - only the first one is touched
-               assertRendered(new MyTestPage(
-                       "<span class='label-text'>text</span><span 
class='label-text'>text</span>"),
-                       "<span class='label-text'>t</span><span 
class='label-text'>text</span>");
+               assertRendered(new MyTestPage(" a <div> b 
<wicket:label>text</wicket:label> c </div> d"),
+                       " a <div> b t c </div> d");
 
                // no span - no insertion
                assertRendered(new MyTestPage(" text "), " text ");
@@ -69,16 +62,10 @@ public class AutoLabelTest extends Wicke
                assertRendered(new MyTestPage(""), "></label>");
 
                // empty span tag
-               assertRendered(new MyTestPage("<span 
class='label-text'></span>"),
-                       "<span class='label-text'>t</span>");
+               assertRendered(new MyTestPage("<wicket:label></wicket:label>"), 
">t</label>");
 
                // open/close span tag
-               assertRendered(new MyTestPage("<span class='label-text'/>"),
-                       "<span class='label-text'>t</span>");
-
-               // test additional classes on the span are preserved
-               assertRendered(new MyTestPage("<span class='foo label-text 
bar'/>"),
-                       "<span class='foo label-text bar'>t</span>");
+               assertRendered(new MyTestPage("<wicket:label/>"), ">t</label>");
        }
 
        /** */
@@ -96,7 +83,7 @@ public class AutoLabelTest extends Wicke
 
                // test form component label is defaulted to the contents of 
span class='label-text'
 
-               MyTestPage page = new MyTestPage("<span 
class='label-text'>text</span>");
+               MyTestPage page = new 
MyTestPage("<wicket:label>text</wicket:label>");
                tester.startPage(page);
                assertEquals("text", 
((MyTestPage)tester.getLastRenderedPage()).field.getLabel()
                        .getObject());
@@ -155,7 +142,7 @@ public class AutoLabelTest extends Wicke
                        public MyTestPage2()
                        {
                                super(
-                                       "<label class='long' 
wicket:for='t'><span class='label-text'>field</span></label>");
+                                       "<label class='long' 
wicket:for='t'><wicket:label>field</wicket:label></label>");
                        }
                }
 
@@ -209,4 +196,4 @@ public class AutoLabelTest extends Wicke
                                "\n<input type='text' 
wicket:id='t'/>\n</form></body></html>");
                }
        }
-}
\ No newline at end of file
+}

Added: 
wicket/trunk/wicket-core/src/test/java/org/apache/wicket/markup/html/form/AutoLabelWithContentTest$LabelWithMessagePage.html
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket-core/src/test/java/org/apache/wicket/markup/html/form/AutoLabelWithContentTest%24LabelWithMessagePage.html?rev=1149042&view=auto
==============================================================================
--- 
wicket/trunk/wicket-core/src/test/java/org/apache/wicket/markup/html/form/AutoLabelWithContentTest$LabelWithMessagePage.html
 (added)
+++ 
wicket/trunk/wicket-core/src/test/java/org/apache/wicket/markup/html/form/AutoLabelWithContentTest$LabelWithMessagePage.html
 Thu Jul 21 05:52:50 2011
@@ -0,0 +1,8 @@
+<html>
+<body>
+    <form wicket:id="form">
+        <label wicket:for="textfield"><wicket:message 
key="foo">blabla</wicket:message></label>
+        <input type="text" wicket:id="textfield"/>
+    </form>
+</body>
+</html>
\ No newline at end of file

Propchange: 
wicket/trunk/wicket-core/src/test/java/org/apache/wicket/markup/html/form/AutoLabelWithContentTest$LabelWithMessagePage.html
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: 
wicket/trunk/wicket-core/src/test/java/org/apache/wicket/markup/html/form/AutoLabelWithContentTest$LabelWithMessagePage.properties
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket-core/src/test/java/org/apache/wicket/markup/html/form/AutoLabelWithContentTest%24LabelWithMessagePage.properties?rev=1149042&view=auto
==============================================================================
--- 
wicket/trunk/wicket-core/src/test/java/org/apache/wicket/markup/html/form/AutoLabelWithContentTest$LabelWithMessagePage.properties
 (added)
+++ 
wicket/trunk/wicket-core/src/test/java/org/apache/wicket/markup/html/form/AutoLabelWithContentTest$LabelWithMessagePage.properties
 Thu Jul 21 05:52:50 2011
@@ -0,0 +1 @@
+foo=my test text

Propchange: 
wicket/trunk/wicket-core/src/test/java/org/apache/wicket/markup/html/form/AutoLabelWithContentTest$LabelWithMessagePage.properties
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: 
wicket/trunk/wicket-core/src/test/java/org/apache/wicket/markup/html/form/AutoLabelWithContentTest$LabelWithNestedComponentsPage.html
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket-core/src/test/java/org/apache/wicket/markup/html/form/AutoLabelWithContentTest%24LabelWithNestedComponentsPage.html?rev=1149042&view=auto
==============================================================================
--- 
wicket/trunk/wicket-core/src/test/java/org/apache/wicket/markup/html/form/AutoLabelWithContentTest$LabelWithNestedComponentsPage.html
 (added)
+++ 
wicket/trunk/wicket-core/src/test/java/org/apache/wicket/markup/html/form/AutoLabelWithContentTest$LabelWithNestedComponentsPage.html
 Thu Jul 21 05:52:50 2011
@@ -0,0 +1,7 @@
+<html>
+<body>
+<form wicket:id="form">
+    <label wicket:for="textfield"><input type="text" 
wicket:id="textfield"/></label>
+</form>
+</body>
+</html>

Propchange: 
wicket/trunk/wicket-core/src/test/java/org/apache/wicket/markup/html/form/AutoLabelWithContentTest$LabelWithNestedComponentsPage.html
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: 
wicket/trunk/wicket-core/src/test/java/org/apache/wicket/markup/html/form/AutoLabelWithContentTest.java
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket-core/src/test/java/org/apache/wicket/markup/html/form/AutoLabelWithContentTest.java?rev=1149042&view=auto
==============================================================================
--- 
wicket/trunk/wicket-core/src/test/java/org/apache/wicket/markup/html/form/AutoLabelWithContentTest.java
 (added)
+++ 
wicket/trunk/wicket-core/src/test/java/org/apache/wicket/markup/html/form/AutoLabelWithContentTest.java
 Thu Jul 21 05:52:50 2011
@@ -0,0 +1,66 @@
+/*
+ * 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.form;
+
+import org.apache.wicket.WicketTestCase;
+import org.apache.wicket.markup.html.WebPage;
+import org.apache.wicket.model.Model;
+import org.apache.wicket.util.tester.WicketTester;
+
+/**
+ * Make sure AutoLabelForInputTagResolver works with nested {@literal 
<wicket:message>} and nested components
+ * to support things like {@literal <label wicket:for="foo"><input 
wicket:id="foo"/></label>}.
+ * 
+ * @author Carl-Eric Menzel <[email protected]>
+ */
+@SuppressWarnings({ "rawtypes", "unchecked" })
+public class AutoLabelWithContentTest extends WicketTestCase
+{
+       public static class LabelWithMessagePage extends WebPage
+       {
+               public LabelWithMessagePage()
+               {
+                       Form form = new Form("form");
+                       add(form);
+                       form.add(new TextField("textfield", Model.of("")));
+               }
+       }
+
+       public void testLabelWithMessage() throws Exception
+       {
+               WicketTester tester = new WicketTester();
+               tester.startPage(LabelWithMessagePage.class);
+               tester.assertContains("<label wicket:for=\"textfield\" 
for=\"textfield2\"><wicket:message key=\"foo\">my test 
text</wicket:message></label>");
+       }
+
+       public static class LabelWithNestedComponentsPage extends WebPage
+       {
+               public LabelWithNestedComponentsPage()
+               {
+                       Form form = new Form("form");
+                       add(form);
+                       form.add(new TextField("textfield", Model.of("")));
+               }
+       }
+
+       public void testLabelWithNestedComponent()
+       {
+               WicketTester tester = new WicketTester();
+               tester.startPage(LabelWithNestedComponentsPage.class);
+               tester.assertContains("<label wicket:for=\"textfield\" 
for=\"textfield2\"><input type=\"text\" wicket:id=\"textfield\" value=\"\" 
name=\"textfield\" id=\"textfield2\"/></label>");
+       }
+}

Propchange: 
wicket/trunk/wicket-core/src/test/java/org/apache/wicket/markup/html/form/AutoLabelWithContentTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: 
wicket/trunk/wicket-core/src/test/java/org/apache/wicket/markup/html/form/AutoLabelWithinEnclosureTest$LabelWithinEnclosurePage.html
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket-core/src/test/java/org/apache/wicket/markup/html/form/AutoLabelWithinEnclosureTest%24LabelWithinEnclosurePage.html?rev=1149042&view=auto
==============================================================================
--- 
wicket/trunk/wicket-core/src/test/java/org/apache/wicket/markup/html/form/AutoLabelWithinEnclosureTest$LabelWithinEnclosurePage.html
 (added)
+++ 
wicket/trunk/wicket-core/src/test/java/org/apache/wicket/markup/html/form/AutoLabelWithinEnclosureTest$LabelWithinEnclosurePage.html
 Thu Jul 21 05:52:50 2011
@@ -0,0 +1,10 @@
+<html>
+<body>
+    <form wicket:id="form">
+        <wicket:enclosure>
+            <label wicket:for="textfield">blabla</label>
+            <input type="text" wicket:id="textfield"/>
+        </wicket:enclosure>
+    </form>
+</body>
+</html>

Propchange: 
wicket/trunk/wicket-core/src/test/java/org/apache/wicket/markup/html/form/AutoLabelWithinEnclosureTest$LabelWithinEnclosurePage.html
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: 
wicket/trunk/wicket-core/src/test/java/org/apache/wicket/markup/html/form/AutoLabelWithinEnclosureTest.java
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket-core/src/test/java/org/apache/wicket/markup/html/form/AutoLabelWithinEnclosureTest.java?rev=1149042&view=auto
==============================================================================
--- 
wicket/trunk/wicket-core/src/test/java/org/apache/wicket/markup/html/form/AutoLabelWithinEnclosureTest.java
 (added)
+++ 
wicket/trunk/wicket-core/src/test/java/org/apache/wicket/markup/html/form/AutoLabelWithinEnclosureTest.java
 Thu Jul 21 05:52:50 2011
@@ -0,0 +1,59 @@
+/*
+ * 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.form;
+
+import org.apache.wicket.WicketTestCase;
+import org.apache.wicket.markup.html.WebPage;
+import org.apache.wicket.model.Model;
+import org.apache.wicket.util.tester.WicketTester;
+
+@SuppressWarnings({ "rawtypes", "serial", "unchecked" })
+public class AutoLabelWithinEnclosureTest extends WicketTestCase
+{
+       public static class LabelWithinEnclosurePage extends WebPage
+       {
+               public LabelWithinEnclosurePage(final boolean textFieldVisible)
+               {
+                       Form form = new Form("form");
+                       add(form);
+                       form.add(new TextField("textfield", Model.of(""))
+                       {
+                               @Override
+                               public boolean isVisible()
+                               {
+                                       return textFieldVisible;
+                               }
+                       });
+               }
+       }
+
+       public void testLabelWithinEnclosure_Visible() throws Exception
+       {
+               WicketTester tester = new WicketTester();
+               tester.startPage(new LabelWithinEnclosurePage(true));
+               tester.dumpPage();
+               tester.assertContains("<label wicket:for=\"textfield\" 
for=\"textfield2\">blabla</label>");
+       }
+
+       public void testLabelWithinEnclosure_Invisible() throws Exception
+       {
+               WicketTester tester = new WicketTester();
+               tester.startPage(new LabelWithinEnclosurePage(false));
+               tester.dumpPage();
+               tester.assertContainsNot("label");
+       }
+}

Propchange: 
wicket/trunk/wicket-core/src/test/java/org/apache/wicket/markup/html/form/AutoLabelWithinEnclosureTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain


Reply via email to