@SupportsInformalParameters public class Label extends Object
| Name | Type | Flags | Default | Default Prefix |
|---|---|---|---|---|
| clientId | String | Since 5.6.0 | literal | |
| Used to explicitly set the client-side id of the element for this component. Normally this is not bound (or null) and org.apache.tapestry5.services.javascript.JavaScriptSupport#allocateClientId(org.apache.tapestry5.ComponentResources) is used to generate a unique client-id based on the component's id. In some cases, when creating client-side behaviors, it is useful to explicitly set a unique id for an element using this parameter. Certain values, such as "submit", "method", "reset", etc., will cause client-side conflicts and are not allowed; using such will cause a runtime exception. | ||||
| for | org. | Required, Not Null | component | |
| 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). | ||||
| ignoreBody | boolean | prop | ||
| 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. | ||||
<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.
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.
public Label()
5.6.4 - Copyright © 2003-2021 The Apache Software Foundation.