Commits

mbogaert  committed d63169b

WW-717: added "for" to label.

git-svn-id: http://svn.opensymphony.com/svn/webwork/trunk@676573baa09-0c28-0410-bef9-dab3c582ae83

  • Participants
  • Parent commits cb52760

Comments (0)

Files changed (4)

File src/java/com/opensymphony/webwork/views/jsp/ui/LabelTag.java

      */
     final public static String TEMPLATE = "label";
 
+    protected String forAttr;
+
+    public void setFor(String aFor) {
+        this.forAttr = aFor;
+    }
+
     //~ Methods ////////////////////////////////////////////////////////////////
 
     protected String getDefaultTemplate() {
     protected void evaluateExtraParams(OgnlValueStack stack) {
         super.evaluateExtraParams(stack);
 
+        if (forAttr != null) {
+            addParameter("for", findString(forAttr));
+        }
+
         // try value first, then name (this overrides the default behavior in the superclass)
         if (valueAttr != null) {
             addParameter("nameValue", findString(valueAttr));

File src/java/template/simple/label.vm

 #if ($parameters.id)               id="$!webwork.htmlEncode($parameters.id)"                #end
 #if ($parameters.cssClass)         class="$!webwork.htmlEncode($parameters.cssClass)"       #end
 #if ($parameters.cssStyle)         style="$!webwork.htmlEncode($parameters.cssStyle)"       #end
+#if ($parameters.for)              for="$!webwork.htmlEncode($parameters.for)"              #end
 >#if ($parameters.nameValue)$!webwork.htmlEncode($parameters.nameValue)#end</label>

File src/test/com/opensymphony/webwork/views/jsp/ui/Label-2.txt

 <tr>
     <td align="right" valign="top"><label class="label">mylabel:</label></td>
-    <td><label >foo</label></td>
+    <td><label for="for" >foo</label></td>
 </tr>

File src/test/com/opensymphony/webwork/views/jsp/ui/LabelTest.java

         tag.setPageContext(pageContext);
         tag.setLabel("'mylabel'");
         tag.setName("'foo'");
+        tag.setFor("'for'");
 
         int result = tag.doEndTag();