Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.tapestry5.corelib.components
Class Label

    java.lang.Object
      org.apache.tapestry5.corelib.components.Label

    @SupportsInformalParameters
    public class Label

extends java.lang.Object

Generates a <label> element for a particular field.

A Label will render its body, if it has one. However, in most cases it will not have a body, and will render its field's label as it's body. Remember, however, that it is the field label that will be used in any error messages. The Label component allows for client- and server-side validation error decorations.

Component Parameters
Name | Description | Type | Flags | Default | Default Prefix | Since
--- | --- | --- | --- | --- | --- | ---
for | The for parameter is used to identify the org.apache.tapestry5.Field linked to this label (it is named this way because it results in the for attribute of the label element). | org.apache.tapestry5.Field | Required, Not Null |  | component |
ignoreBody | If true, then the body of the label element (in the template) is ignored. This is used when a designer places a value inside the label element for WYSIWYG purposes, but it should be replaced with a different (probably, localized) value at runtime. The default is false, so a body will be used if present and the field's label will only be used if the body is empty or blank. | boolean |  |  | prop |

Examples:

  ### Search.tml

      <html xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd">
          <body>

              <t:form>
                  <t:label for="search"/>
                  <t:textfield t:id="search" size="50"/>

                  <t:checkbox t:id="all"/>
                  <t:label for="all">
                      Include out of date records
                  </t:label>

              . . .

      </html>

  This demonstrates that the Label can come before or after the form control element component (the TextField and Checkbox components). When a Label has a body, that takes precendence over the field's label, though the field's label is what's used in any error messages.

Notes:

  The Label component is very important for user accessibility. A user will be able to click on the label to move the cursor into the corresponding field.

  The Label component supports informal parameters; this can be very useful for adding the `accesskey` attribute supported by most browsers.

Constructor Summary
`Label()`

Method Summary

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### Label

    public Label()

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2003-2012 The Apache Software Foundation.