public class LabelTag extends AbstractHtmlElementTag
<label>
tag renders a form field label in an HTML 'label' tag.
See the "formTags" showcase application that ships with the full Spring distribution for an example of this class in action.
Attribute | Required? | Runtime Expression? | Description |
---|---|---|---|
cssClass |
false |
true |
HTML Optional Attribute. |
cssErrorClass |
false |
true |
HTML Optional Attribute. Used only when errors are present. |
cssStyle |
false |
true |
HTML Optional Attribute |
dir |
false |
true |
HTML Standard Attribute |
for |
false |
true |
HTML Standard Attribute |
htmlEscape |
false |
true |
Enable/disable HTML escaping of rendered values. |
id |
false |
true |
HTML Standard Attribute |
lang |
false |
true |
HTML Standard Attribute |
onclick |
false |
true |
HTML Event Attribute |
ondblclick |
false |
true |
HTML Event Attribute |
onkeydown |
false |
true |
HTML Event Attribute |
onkeypress |
false |
true |
HTML Event Attribute |
onkeyup |
false |
true |
HTML Event Attribute |
onmousedown |
false |
true |
HTML Event Attribute |
onmousemove |
false |
true |
HTML Event Attribute |
onmouseout |
false |
true |
HTML Event Attribute |
onmouseover |
false |
true |
HTML Event Attribute |
onmouseup |
false |
true |
HTML Event Attribute |
path |
true |
true |
Path to errors object for data binding |
tabindex |
false |
true |
HTML Standard Attribute |
title |
false |
true |
HTML Standard Attribute |
CLASS_ATTRIBUTE, DIR_ATTRIBUTE, LANG_ATTRIBUTE, ONCLICK_ATTRIBUTE, ONDBLCLICK_ATTRIBUTE, ONKEYDOWN_ATTRIBUTE, ONKEYPRESS_ATTRIBUTE, ONKEYUP_ATTRIBUTE, ONMOUSEDOWN_ATTRIBUTE, ONMOUSEMOVE_ATTRIBUTE, ONMOUSEOUT_ATTRIBUTE, ONMOUSEOVER_ATTRIBUTE, ONMOUSEUP_ATTRIBUTE, STYLE_ATTRIBUTE, TABINDEX_ATTRIBUTE, TITLE_ATTRIBUTE
NESTED_PATH_VARIABLE_NAME
logger, REQUEST_CONTEXT_PAGE_ATTRIBUTE
pageContext
EVAL_BODY_AGAIN
EVAL_BODY_INCLUDE, EVAL_PAGE, SKIP_BODY, SKIP_PAGE
Constructor and Description |
---|
LabelTag() |
Modifier and Type | Method and Description |
---|---|
protected String |
autogenerateFor()
Autogenerate the '
for ' attribute value for this tag. |
int |
doEndTag()
Close the '
label ' tag. |
void |
doFinally()
Disposes of the
TagWriter instance. |
protected String |
getFor()
Get the value of the '
id ' attribute. |
protected String |
getName()
Overrides
#getName() to always return null ,
because the 'name ' attribute is not supported by the
'label ' tag. |
protected String |
resolveFor()
Determine the '
for ' attribute value for this tag,
autogenerating one if none specified. |
void |
setFor(String forId)
Set the value of the '
for ' attribute. |
protected int |
writeTagContent(TagWriter tagWriter)
Writes the opening '
label ' tag and forces a block tag so
that body content is written correctly. |
getCssClass, getCssErrorClass, getCssStyle, getDir, getDynamicAttributes, getLang, getOnclick, getOndblclick, getOnkeydown, getOnkeypress, getOnkeyup, getOnmousedown, getOnmousemove, getOnmouseout, getOnmouseover, getOnmouseup, getTabindex, getTitle, isValidDynamicAttribute, resolveCssClass, setCssClass, setCssErrorClass, setCssStyle, setDir, setDynamicAttribute, setLang, setOnclick, setOndblclick, setOnkeydown, setOnkeypress, setOnkeyup, setOnmousedown, setOnmousemove, setOnmouseout, setOnmouseover, setOnmouseup, setTabindex, setTitle, writeDefaultAttributes, writeOptionalAttributes
autogenerateId, convertToDisplayString, getBindStatus, getBoundValue, getEditor, getId, getNestedPath, getPath, getPropertyEditor, getPropertyPath, processFieldValue, resolveId, setId, setPath
createTagWriter, doStartTagInternal, evaluate, getDisplayString, getDisplayString, isDefaultHtmlEscape, writeOptionalAttribute
htmlEscape, isHtmlEscape, isResponseEncodedHtmlEscape, setHtmlEscape
doCatch, doStartTag, getRequestContext
doAfterBody, findAncestorWithClass, getParent, getValue, getValues, release, removeValue, setPageContext, setParent, setValue
public void setFor(String forId)
for
' attribute.
Defaults to the value of AbstractDataBoundFormElementTag.getPath()
; may be a runtime expression.
@Nullable protected String getFor()
id
' attribute.
May be a runtime expression.
protected int writeTagContent(TagWriter tagWriter) throws JspException
label
' tag and forces a block tag so
that body content is written correctly.writeTagContent
in class AbstractFormTag
Tag.EVAL_BODY_INCLUDE
JspException
@Nullable protected String getName() throws JspException
#getName()
to always return null
,
because the 'name
' attribute is not supported by the
'label
' tag.getName
in class AbstractDataBoundFormElementTag
name
' attributeJspException
protected String resolveFor() throws JspException
for
' attribute value for this tag,
autogenerating one if none specified.JspException
getFor()
,
autogenerateFor()
protected String autogenerateFor() throws JspException
for
' attribute value for this tag.
The default implementation delegates to AbstractDataBoundFormElementTag.getPropertyPath()
,
deleting invalid characters (such as "[" or "]").
JspException
public int doEndTag() throws JspException
label
' tag.doEndTag
in interface Tag
doEndTag
in class TagSupport
JspException
public void doFinally()
TagWriter
instance.doFinally
in interface TryCatchFinally
doFinally
in class AbstractDataBoundFormElementTag