Stripes Tag Library
Tag label


Label tag that can look up localized field labels and render differently when the labelled field is in error. While the label field is usually used to generated form field labels, it can be used to generate HTML label tags with arbitrary localized or non-localized values.

It is important to understand the relationship between the name and for attributes of the stripes:label tag. The for attribute is used directly to generated the for attribute of the generated HTML label tag, and as such should correspond to the HTML id attribute of the input tag for which it is a label. If the name attribute is omitted then the value of the for attribute will also be used as the name attribute.

The value of the label is set by searching for a non-null value in the following order:

In the case of indexed or mapped form fields (e.g. foo[3].bar) the indexing and mapping will be removed from the name prior to using it to lookup labels (e.g. foo.bar). This is done to remain consistent with the way field names are looked up for error messages.

It should be noted that in cases where a form field and HTML control are one-to-one (e.g. text, password, select) the name of the label will usually equal the name of the control. However, this need not be the case. You may use any value for the name of the label, but the label will only perform error rendering correctly if the name is equal to the name of the form field being labelled. To illustrate this point consider the following example:

<th>
    <stripes:label for="bug.status"/>:
</th>
<td>
    <c:forEach var="status" items="<%=Status.values()%>">
        <stripes:radio id="bug.status.${stripes:enumName(status)}"
                       name="bug.status"
                       value="${stripes:enumName(status)}"/>
        <stripes:label for="bug.status.${stripes:enumName(status)}">
            ${stripes:enumName(status)}
        </stripes:label>
    </c:forEach>
</td>

The above example uses one label tag at the top (with for="bug.status") that labels a row in the table and will display differently when the bug.status field is in error. It then employs a label tag for each radio button. These are bound to the individual radio buttons (clicking on the label will select the appropriate radio button), and default to the name of the enum value if a localized name isn't found. Since these labels do not match the field name exactly, they will not render differently when the field is in error.



Tag Information
Tag Classnet.sourceforge.stripes.tag.InputLabelTag
TagExtraInfo ClassNone
Body ContentJSP
Display Namelabel

Attributes
NameRequiredRequest-timeTypeDescription
namefalsetruejava.lang.String The name of the field being labelled (or of the label if it is not specific to a field) if the name of the field is not the same as the HTML id of the field. If the name and id are the same, the for attribute should be used alone.
forfalsetruejava.lang.String The HTML id of the field/control being labelled. If the name attribute is omitted, the value of this attribute will also be used as the name.
accesskeyfalsetruejava.lang.StringKeyboard shortcut to access the element. (HTML Pass-through)
classfalsetruejava.lang.StringThe CSS class to be applied to the element. (HTML Pass-through)
dirfalsetruejava.lang.StringText direction. (HTML Pass-through)
idfalsetruejava.lang.StringA unique identifier for the HTML tag on the page. (HTML Pass-through)
langfalsetruejava.lang.StringThe language code of the element. (HTML Pass-through)
onblurfalsetruejava.lang.StringScripting code run when the element loses focus. (HTML Pass-through)
onchangefalsetruejava.lang.StringScripting code run when the element changes. (HTML Pass-through)
onclickfalsetruejava.lang.StringScripting code run on each mouse click. (HTML Pass-through)
ondblclickfalsetruejava.lang.StringScripting code run on a double-click of the mouse. (HTML Pass-through)
onfocusfalsetruejava.lang.StringScripting code run when the element acquires focus. (HTML Pass-through)
onkeydownfalsetruejava.lang.StringScripting code run when a key is depressed. (HTML Pass-through)
onkeypressfalsetruejava.lang.StringScripting code run when a key is pressed and released. (HTML Pass-through)
onkeyupfalsetruejava.lang.StringScripting code run when a key is released. (HTML Pass-through)
onmousedownfalsetruejava.lang.StringScripting code run when a mouse button is depressed. (HTML Pass-through)
onmousemovefalsetruejava.lang.StringScripting code run when the mouse pointer is moved. (HTML Pass-through)
onmouseoutfalsetruejava.lang.StringScripting code run when the mouse pointer moves out of the element. (HTML Pass-through)
onmouseoverfalsetruejava.lang.StringScripting code run when the mouse pointer moves over the element. (HTML Pass-through)
onmouseupfalsetruejava.lang.StringScripting code run when a mouse button is released. (HTML Pass-through)
onselectfalsetruejava.lang.StringScripting code run when an element is selected. (HTML Pass-through)
stylefalsetruejava.lang.StringInline CSS style fragment that applies to the element (HTML Pass-through)
tabindexfalsetruejava.lang.StringThe tab order of the element. (HTML Pass-through)
titlefalsetruejava.lang.StringTool-tip text for the element. (HTML Pass-through)

Variables
No Variables Defined.


Output Generated by Tag Library Documentation Generator. Java, JSP, and JavaServer Pages are trademarks or registered trademarks of Sun Microsystems, Inc. in the US and other countries. Copyright 2002-4 Sun Microsystems, Inc. 4150 Network Circle Santa Clara, CA 95054, U.S.A. All Rights Reserved.