Author: ivaynberg
Date: Fri Jul 15 03:32:46 2011
New Revision: 1146947

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

Issue: WICKET-3903

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

Modified: 
wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/markup/html/form/AutoLabelResolver.java
URL: 
http://svn.apache.org/viewvc/wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/markup/html/form/AutoLabelResolver.java?rev=1146947&r1=1146946&r2=1146947&view=diff
==============================================================================
--- 
wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/markup/html/form/AutoLabelResolver.java
 (original)
+++ 
wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/markup/html/form/AutoLabelResolver.java
 Fri Jul 15 03:32:46 2011
@@ -21,16 +21,9 @@ import org.apache.wicket.Component.IVisi
 import org.apache.wicket.MarkupContainer;
 import org.apache.wicket.WicketRuntimeException;
 import org.apache.wicket.markup.ComponentTag;
-import org.apache.wicket.markup.MarkupElement;
 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.resolver.IComponentResolver;
-import org.apache.wicket.model.Model;
-import org.apache.wicket.util.string.AppendingStringBuffer;
-import org.apache.wicket.util.string.Strings;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -45,15 +38,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='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='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>
- * </ul>
- * 
+ * <li>Appends {@code disabled} css class to the {@code <label>} tag if the 
referenced form
+ * component has is not enabled in hierarchy</li>
  * <p>
  * The value of the {@code wicket:for} atribute can either contain an id of 
the form component or a
  * path to it using the standard {@code :} path separator. Note that {@code 
..} can be used as part
@@ -64,6 +50,8 @@ import org.slf4j.LoggerFactory;
  * searched from the closest parent to the page.
  * </p>
  * 
+<<<<<<< .mine
+=======
  * <p>
  * Given markup like this:
  * 
@@ -80,7 +68,9 @@ import org.slf4j.LoggerFactory;
  * {@code Name} based on the markup.
  * </p>
  * 
+>>>>>>> .r1146946
  * @author igor
+ * @author Carl-Eric Menzel <[email protected]>
  */
 public class AutoLabelResolver implements IComponentResolver
 {
@@ -127,7 +117,7 @@ public class AutoLabelResolver implement
                return true;
        }
 
-       protected Component findRelatedComponent(MarkupContainer container, 
final String id)
+       static Component findRelatedComponent(MarkupContainer container, final 
String id)
        {
                // try the quick and easy route first
 
@@ -208,206 +198,25 @@ public class AutoLabelResolver implement
                                {
                                        tag.append("class", "error", " ");
                                }
+                               if (!fc.isEnabledInHierarchy())
+                               {
+                                       tag.append("class", "disabled", " ");
+                               }
                        }
                }
 
                @Override
-               protected void onComponentTagBody(MarkupStream markupStream, 
ComponentTag openTag)
+               public boolean isTransparentResolver()
                {
-                       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)
-                               {
-                                       FormComponent<?> fc = 
(FormComponent<?>)component;
-                                       String markupLabel = 
markup.substring(start, end);
-                                       fc.setLabel(Model.of(markupLabel));
-                                       super.onComponentTagBody(markupStream, 
openTag);
-                               }
-                       }
+                       return true;
                }
 
                /**
-                * 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 = (XmlTag)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(MarkupElement element)
+               public Component getRelatedComponent()
                {
-                       if (!(element instanceof XmlTag))
-                               return false;
-
-                       XmlTag tag = (XmlTag)element;
-
-                       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/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/markup/html/form/AutoLabelTagHandler.java
URL: 
http://svn.apache.org/viewvc/wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/markup/html/form/AutoLabelTagHandler.java?rev=1146947&r1=1146946&r2=1146947&view=diff
==============================================================================
--- 
wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/markup/html/form/AutoLabelTagHandler.java
 (original)
+++ 
wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/markup/html/form/AutoLabelTagHandler.java
 Fri Jul 15 03:32:46 2011
@@ -63,6 +63,7 @@ public class AutoLabelTagHandler extends
 
                tag.setId(getClass().getName());
                tag.setModified(true);
+               tag.setAutoComponentTag(true);
                return tag;
        }
 

Added: 
wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/markup/html/form/AutoLabelTextResolver.java
URL: 
http://svn.apache.org/viewvc/wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/markup/html/form/AutoLabelTextResolver.java?rev=1146947&view=auto
==============================================================================
--- 
wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/markup/html/form/AutoLabelTextResolver.java
 (added)
+++ 
wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/markup/html/form/AutoLabelTextResolver.java
 Fri Jul 15 03:32:46 2011
@@ -0,0 +1,253 @@
+/*
+ * 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.RequestCycle;
+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.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.OPEN);
+                       }
+                       super.onComponentTag(tag);
+               }
+
+               @Override
+               protected 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 boolean 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 add 
our label.
+                               container.autoAdd(new TextLabel("label" + 
container.getPage().getAutoIndex2(),
+                                       related), markupStream);
+                               return true;
+                       }
+               }
+               return false;
+       }
+
+}

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

Modified: 
wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/markup/html/internal/ResponseBufferZone.java
URL: 
http://svn.apache.org/viewvc/wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/markup/html/internal/ResponseBufferZone.java?rev=1146947&r1=1146946&r2=1146947&view=diff
==============================================================================
--- 
wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/markup/html/internal/ResponseBufferZone.java
 (original)
+++ 
wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/markup/html/internal/ResponseBufferZone.java
 Fri Jul 15 03:32:46 2011
@@ -26,7 +26,7 @@ import org.apache.wicket.response.String
  * 
  * @author igor.vaynberg
  */
-abstract class ResponseBufferZone
+public abstract class ResponseBufferZone
 {
        private final RequestCycle cycle;
        private final MarkupStream stream;

Modified: 
wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/protocol/http/WebApplication.java
URL: 
http://svn.apache.org/viewvc/wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/protocol/http/WebApplication.java?rev=1146947&r1=1146946&r2=1146947&view=diff
==============================================================================
--- 
wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/protocol/http/WebApplication.java
 (original)
+++ 
wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/protocol/http/WebApplication.java
 Fri Jul 15 03:32:46 2011
@@ -34,6 +34,7 @@ import org.apache.wicket.Response;
 import org.apache.wicket.Session;
 import org.apache.wicket.WicketRuntimeException;
 import org.apache.wicket.ajax.AjaxRequestTarget;
+import org.apache.wicket.markup.html.form.AutoLabelTextResolver;
 import org.apache.wicket.markup.html.form.AutoLabelResolver;
 import org.apache.wicket.markup.html.pages.AccessDeniedPage;
 import org.apache.wicket.markup.html.pages.InternalErrorPage;
@@ -557,6 +558,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/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/util/tester/BaseWicketTester.java
URL: 
http://svn.apache.org/viewvc/wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/util/tester/BaseWicketTester.java?rev=1146947&r1=1146946&r2=1146947&view=diff
==============================================================================
--- 
wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/util/tester/BaseWicketTester.java
 (original)
+++ 
wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/util/tester/BaseWicketTester.java
 Fri Jul 15 03:32:46 2011
@@ -697,6 +697,19 @@ public class BaseWicketTester extends Mo
        }
 
        /**
+        * 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", 
getServletResponse().getDocument()
+                       .matches("(?s).*" + pattern + ".*"));
+       }
+
+       /**
         * assert the model of {@link ListView} use expectedList
         * 
         * @param path

Modified: 
wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/util/tester/WicketTester.java
URL: 
http://svn.apache.org/viewvc/wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/util/tester/WicketTester.java?rev=1146947&r1=1146946&r2=1146947&view=diff
==============================================================================
--- 
wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/util/tester/WicketTester.java
 (original)
+++ 
wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/util/tester/WicketTester.java
 Fri Jul 15 03:32:46 2011
@@ -416,6 +416,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
@@ -694,4 +705,6 @@ public class WicketTester extends BaseWi
                        throw new AssertionFailedError(result.getMessage());
                }
        }
+
+
 }

Added: 
wicket/branches/wicket-1.4.x/wicket/src/test/java/org/apache/wicket/markup/html/form/AutoFormLabelPickupTest$PickUpLabelPage.html
URL: 
http://svn.apache.org/viewvc/wicket/branches/wicket-1.4.x/wicket/src/test/java/org/apache/wicket/markup/html/form/AutoFormLabelPickupTest%24PickUpLabelPage.html?rev=1146947&view=auto
==============================================================================
--- 
wicket/branches/wicket-1.4.x/wicket/src/test/java/org/apache/wicket/markup/html/form/AutoFormLabelPickupTest$PickUpLabelPage.html
 (added)
+++ 
wicket/branches/wicket-1.4.x/wicket/src/test/java/org/apache/wicket/markup/html/form/AutoFormLabelPickupTest$PickUpLabelPage.html
 Fri Jul 15 03:32:46 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/branches/wicket-1.4.x/wicket/src/test/java/org/apache/wicket/markup/html/form/AutoFormLabelPickupTest$PickUpLabelPage.html
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: 
wicket/branches/wicket-1.4.x/wicket/src/test/java/org/apache/wicket/markup/html/form/AutoFormLabelPickupTest$PickUpLabelPage.properties
URL: 
http://svn.apache.org/viewvc/wicket/branches/wicket-1.4.x/wicket/src/test/java/org/apache/wicket/markup/html/form/AutoFormLabelPickupTest%24PickUpLabelPage.properties?rev=1146947&view=auto
==============================================================================
--- 
wicket/branches/wicket-1.4.x/wicket/src/test/java/org/apache/wicket/markup/html/form/AutoFormLabelPickupTest$PickUpLabelPage.properties
 (added)
+++ 
wicket/branches/wicket-1.4.x/wicket/src/test/java/org/apache/wicket/markup/html/form/AutoFormLabelPickupTest$PickUpLabelPage.properties
 Fri Jul 15 03:32:46 2011
@@ -0,0 +1 @@
+msg=label from properties

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

Added: 
wicket/branches/wicket-1.4.x/wicket/src/test/java/org/apache/wicket/markup/html/form/AutoFormLabelPickupTest$PrintLabelPage.html
URL: 
http://svn.apache.org/viewvc/wicket/branches/wicket-1.4.x/wicket/src/test/java/org/apache/wicket/markup/html/form/AutoFormLabelPickupTest%24PrintLabelPage.html?rev=1146947&view=auto
==============================================================================
--- 
wicket/branches/wicket-1.4.x/wicket/src/test/java/org/apache/wicket/markup/html/form/AutoFormLabelPickupTest$PrintLabelPage.html
 (added)
+++ 
wicket/branches/wicket-1.4.x/wicket/src/test/java/org/apache/wicket/markup/html/form/AutoFormLabelPickupTest$PrintLabelPage.html
 Fri Jul 15 03:32:46 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/branches/wicket-1.4.x/wicket/src/test/java/org/apache/wicket/markup/html/form/AutoFormLabelPickupTest$PrintLabelPage.html
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: 
wicket/branches/wicket-1.4.x/wicket/src/test/java/org/apache/wicket/markup/html/form/AutoFormLabelPickupTest$PrintLabelPage.properties
URL: 
http://svn.apache.org/viewvc/wicket/branches/wicket-1.4.x/wicket/src/test/java/org/apache/wicket/markup/html/form/AutoFormLabelPickupTest%24PrintLabelPage.properties?rev=1146947&view=auto
==============================================================================
--- 
wicket/branches/wicket-1.4.x/wicket/src/test/java/org/apache/wicket/markup/html/form/AutoFormLabelPickupTest$PrintLabelPage.properties
 (added)
+++ 
wicket/branches/wicket-1.4.x/wicket/src/test/java/org/apache/wicket/markup/html/form/AutoFormLabelPickupTest$PrintLabelPage.properties
 Fri Jul 15 03:32:46 2011
@@ -0,0 +1 @@
+msg=label from properties

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

Added: 
wicket/branches/wicket-1.4.x/wicket/src/test/java/org/apache/wicket/markup/html/form/AutoFormLabelPickupTest.java
URL: 
http://svn.apache.org/viewvc/wicket/branches/wicket-1.4.x/wicket/src/test/java/org/apache/wicket/markup/html/form/AutoFormLabelPickupTest.java?rev=1146947&view=auto
==============================================================================
--- 
wicket/branches/wicket-1.4.x/wicket/src/test/java/org/apache/wicket/markup/html/form/AutoFormLabelPickupTest.java
 (added)
+++ 
wicket/branches/wicket-1.4.x/wicket/src/test/java/org/apache/wicket/markup/html/form/AutoFormLabelPickupTest.java
 Fri Jul 15 03:32:46 2011
@@ -0,0 +1,96 @@
+/*
+ * 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")));
+               System.out.println(tester.getServletResponse().getDocument());
+               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.dumpPage();
+               tester.assertContains("<label>label from markup without 
autolabel</label>");
+               assertEquals(
+                       "label from markup without autolabel",
+                       
((FormComponent)tester.getComponentFromLastRenderedPage("form:inputWithoutAutolabel")).getLabel()
+                               .getObject());
+       }
+}

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

Modified: 
wicket/branches/wicket-1.4.x/wicket/src/test/java/org/apache/wicket/markup/html/form/AutoLabelTest.java
URL: 
http://svn.apache.org/viewvc/wicket/branches/wicket-1.4.x/wicket/src/test/java/org/apache/wicket/markup/html/form/AutoLabelTest.java?rev=1146947&r1=1146946&r2=1146947&view=diff
==============================================================================
--- 
wicket/branches/wicket-1.4.x/wicket/src/test/java/org/apache/wicket/markup/html/form/AutoLabelTest.java
 (original)
+++ 
wicket/branches/wicket-1.4.x/wicket/src/test/java/org/apache/wicket/markup/html/form/AutoLabelTest.java
 Fri Jul 15 03:32:46 2011
@@ -45,24 +45,17 @@ 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 ");
@@ -71,16 +64,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");
 
                // 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");
        }
 
        public void testMarkupIntoLabelInsertion()
@@ -95,7 +82,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());
@@ -107,7 +94,7 @@ public class AutoLabelTest extends Wicke
                {
                        public MyTestPage()
                        {
-                               super("<label wicket:for='t'><span 
class='label-text'>field</span></label>");
+                               super("<label 
wicket:for='t'><wicket:label>field</wicket:label></label>");
                        }
                }
 
@@ -138,7 +125,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>");
                        }
                }
 

Added: 
wicket/branches/wicket-1.4.x/wicket/src/test/java/org/apache/wicket/markup/html/form/AutoLabelWithContentTest$LabelWithMessagePage.html
URL: 
http://svn.apache.org/viewvc/wicket/branches/wicket-1.4.x/wicket/src/test/java/org/apache/wicket/markup/html/form/AutoLabelWithContentTest%24LabelWithMessagePage.html?rev=1146947&view=auto
==============================================================================
--- 
wicket/branches/wicket-1.4.x/wicket/src/test/java/org/apache/wicket/markup/html/form/AutoLabelWithContentTest$LabelWithMessagePage.html
 (added)
+++ 
wicket/branches/wicket-1.4.x/wicket/src/test/java/org/apache/wicket/markup/html/form/AutoLabelWithContentTest$LabelWithMessagePage.html
 Fri Jul 15 03:32:46 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>

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

Added: 
wicket/branches/wicket-1.4.x/wicket/src/test/java/org/apache/wicket/markup/html/form/AutoLabelWithContentTest$LabelWithMessagePage.properties
URL: 
http://svn.apache.org/viewvc/wicket/branches/wicket-1.4.x/wicket/src/test/java/org/apache/wicket/markup/html/form/AutoLabelWithContentTest%24LabelWithMessagePage.properties?rev=1146947&view=auto
==============================================================================
--- 
wicket/branches/wicket-1.4.x/wicket/src/test/java/org/apache/wicket/markup/html/form/AutoLabelWithContentTest$LabelWithMessagePage.properties
 (added)
+++ 
wicket/branches/wicket-1.4.x/wicket/src/test/java/org/apache/wicket/markup/html/form/AutoLabelWithContentTest$LabelWithMessagePage.properties
 Fri Jul 15 03:32:46 2011
@@ -0,0 +1 @@
+foo=my test text

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

Added: 
wicket/branches/wicket-1.4.x/wicket/src/test/java/org/apache/wicket/markup/html/form/AutoLabelWithContentTest$LabelWithNestedComponentsPage.html
URL: 
http://svn.apache.org/viewvc/wicket/branches/wicket-1.4.x/wicket/src/test/java/org/apache/wicket/markup/html/form/AutoLabelWithContentTest%24LabelWithNestedComponentsPage.html?rev=1146947&view=auto
==============================================================================
--- 
wicket/branches/wicket-1.4.x/wicket/src/test/java/org/apache/wicket/markup/html/form/AutoLabelWithContentTest$LabelWithNestedComponentsPage.html
 (added)
+++ 
wicket/branches/wicket-1.4.x/wicket/src/test/java/org/apache/wicket/markup/html/form/AutoLabelWithContentTest$LabelWithNestedComponentsPage.html
 Fri Jul 15 03:32:46 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/branches/wicket-1.4.x/wicket/src/test/java/org/apache/wicket/markup/html/form/AutoLabelWithContentTest$LabelWithNestedComponentsPage.html
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: 
wicket/branches/wicket-1.4.x/wicket/src/test/java/org/apache/wicket/markup/html/form/AutoLabelWithContentTest.java
URL: 
http://svn.apache.org/viewvc/wicket/branches/wicket-1.4.x/wicket/src/test/java/org/apache/wicket/markup/html/form/AutoLabelWithContentTest.java?rev=1146947&view=auto
==============================================================================
--- 
wicket/branches/wicket-1.4.x/wicket/src/test/java/org/apache/wicket/markup/html/form/AutoLabelWithContentTest.java
 (added)
+++ 
wicket/branches/wicket-1.4.x/wicket/src/test/java/org/apache/wicket/markup/html/form/AutoLabelWithContentTest.java
 Fri Jul 15 03:32:46 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/branches/wicket-1.4.x/wicket/src/test/java/org/apache/wicket/markup/html/form/AutoLabelWithContentTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: 
wicket/branches/wicket-1.4.x/wicket/src/test/java/org/apache/wicket/markup/html/form/AutoLabelWithinEnclosureTest$LabelWithinEnclosurePage.html
URL: 
http://svn.apache.org/viewvc/wicket/branches/wicket-1.4.x/wicket/src/test/java/org/apache/wicket/markup/html/form/AutoLabelWithinEnclosureTest%24LabelWithinEnclosurePage.html?rev=1146947&view=auto
==============================================================================
--- 
wicket/branches/wicket-1.4.x/wicket/src/test/java/org/apache/wicket/markup/html/form/AutoLabelWithinEnclosureTest$LabelWithinEnclosurePage.html
 (added)
+++ 
wicket/branches/wicket-1.4.x/wicket/src/test/java/org/apache/wicket/markup/html/form/AutoLabelWithinEnclosureTest$LabelWithinEnclosurePage.html
 Fri Jul 15 03:32:46 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/branches/wicket-1.4.x/wicket/src/test/java/org/apache/wicket/markup/html/form/AutoLabelWithinEnclosureTest$LabelWithinEnclosurePage.html
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: 
wicket/branches/wicket-1.4.x/wicket/src/test/java/org/apache/wicket/markup/html/form/AutoLabelWithinEnclosureTest.java
URL: 
http://svn.apache.org/viewvc/wicket/branches/wicket-1.4.x/wicket/src/test/java/org/apache/wicket/markup/html/form/AutoLabelWithinEnclosureTest.java?rev=1146947&view=auto
==============================================================================
--- 
wicket/branches/wicket-1.4.x/wicket/src/test/java/org/apache/wicket/markup/html/form/AutoLabelWithinEnclosureTest.java
 (added)
+++ 
wicket/branches/wicket-1.4.x/wicket/src/test/java/org/apache/wicket/markup/html/form/AutoLabelWithinEnclosureTest.java
 Fri Jul 15 03:32:46 2011
@@ -0,0 +1,64 @@
+/*
+ * 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");
+               tester.assertContains("<wicket:enclosure 
child=\"textfield\"></wicket:enclosure>");
+       }
+
+
+}

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

Modified: 
wicket/branches/wicket-1.4.x/wicket/src/test/java/org/apache/wicket/markup/html/form/FormHasErrorPage.html
URL: 
http://svn.apache.org/viewvc/wicket/branches/wicket-1.4.x/wicket/src/test/java/org/apache/wicket/markup/html/form/FormHasErrorPage.html?rev=1146947&r1=1146946&r2=1146947&view=diff
==============================================================================
--- 
wicket/branches/wicket-1.4.x/wicket/src/test/java/org/apache/wicket/markup/html/form/FormHasErrorPage.html
 (original)
+++ 
wicket/branches/wicket-1.4.x/wicket/src/test/java/org/apache/wicket/markup/html/form/FormHasErrorPage.html
 Fri Jul 15 03:32:46 2011
@@ -10,7 +10,7 @@
                <div wicket:id="invalidPanel">[invalidPanel]</div>
                <input wicket:id="submitComponent" type="button" value="Click 
to test Panel" />
                <div>
-                       <input wicket:id="formComponent" type="checkbox" />
+                       <input wicket:id="labeled" type="checkbox" />
                </div>
                <input wicket:id="submitFormComponent" type="button" 
value="Click to test FormComponent" />
                <br />

Modified: 
wicket/branches/wicket-1.4.x/wicket/src/test/java/org/apache/wicket/markup/html/form/FormHasErrorPage.java
URL: 
http://svn.apache.org/viewvc/wicket/branches/wicket-1.4.x/wicket/src/test/java/org/apache/wicket/markup/html/form/FormHasErrorPage.java?rev=1146947&r1=1146946&r2=1146947&view=diff
==============================================================================
--- 
wicket/branches/wicket-1.4.x/wicket/src/test/java/org/apache/wicket/markup/html/form/FormHasErrorPage.java
 (original)
+++ 
wicket/branches/wicket-1.4.x/wicket/src/test/java/org/apache/wicket/markup/html/form/FormHasErrorPage.java
 Fri Jul 15 03:32:46 2011
@@ -59,7 +59,7 @@ public class FormHasErrorPage extends We
                final SubmitLink submitForm = new SubmitLink("submitForm");
 
                final InvalidPanel invalidPanel = new 
InvalidPanel("invalidPanel");
-               final CheckBox formComponent = new CheckBox("formComponent", 
new Model());
+               final CheckBox formComponent = new CheckBox("labeled", new 
Model());
 
                Form form = new Form("form")
                {


Reply via email to