Class LabelTag
- All Implemented Interfaces:
DynamicAttributes,IterationTag,JspTag,Tag,TryCatchFinally,Serializable,EditorAwareTag
<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 |
- Since:
- 2.0
- Author:
- Rob Harrop, Juergen Hoeller
- See Also:
-
Field Summary
Fields inherited from class org.springframework.web.servlet.tags.form.AbstractHtmlElementTag
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_ATTRIBUTEFields inherited from class org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag
NESTED_PATH_VARIABLE_NAMEFields inherited from class org.springframework.web.servlet.tags.RequestContextAwareTag
logger, REQUEST_CONTEXT_PAGE_ATTRIBUTEFields inherited from class jakarta.servlet.jsp.tagext.TagSupport
pageContextFields inherited from interface jakarta.servlet.jsp.tagext.IterationTag
EVAL_BODY_AGAINFields inherited from interface jakarta.servlet.jsp.tagext.Tag
EVAL_BODY_INCLUDE, EVAL_PAGE, SKIP_BODY, SKIP_PAGE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected StringAutogenerate the 'for' attribute value for this tag.intdoEndTag()Close the 'label' tag.voidDisposes of theTagWriterinstance.protected StringgetFor()Get the value of the 'id' attribute.protected StringgetName()Overrides#getName()to always returnnull, because the 'name' attribute is not supported by the 'label' tag.protected StringDetermine the 'for' attribute value for this tag, autogenerating one if none specified.voidSet the value of the 'for' attribute.protected intwriteTagContent(TagWriter tagWriter) Writes the opening 'label' tag and forces a block tag so that body content is written correctly.Methods inherited from class org.springframework.web.servlet.tags.form.AbstractHtmlElementTag
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, writeOptionalAttributesMethods inherited from class org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag
autogenerateId, convertToDisplayString, getBindStatus, getBoundValue, getEditor, getId, getNestedPath, getPath, getPropertyEditor, getPropertyPath, processFieldValue, resolveId, setId, setPathMethods inherited from class org.springframework.web.servlet.tags.form.AbstractFormTag
createTagWriter, doStartTagInternal, evaluate, getDisplayString, getDisplayString, isDefaultHtmlEscape, writeOptionalAttributeMethods inherited from class org.springframework.web.servlet.tags.HtmlEscapingAwareTag
htmlEscape, isHtmlEscape, isResponseEncodedHtmlEscape, setHtmlEscapeMethods inherited from class org.springframework.web.servlet.tags.RequestContextAwareTag
doCatch, doStartTag, getRequestContextMethods inherited from class jakarta.servlet.jsp.tagext.TagSupport
doAfterBody, findAncestorWithClass, getParent, getValue, getValues, release, removeValue, setPageContext, setParent, setValue
-
Constructor Details
-
LabelTag
public LabelTag()
-
-
Method Details
-
setFor
Set the value of the 'for' attribute.Defaults to the value of
AbstractDataBoundFormElementTag.getPath(); may be a runtime expression. -
getFor
Get the value of the 'id' attribute.May be a runtime expression.
-
writeTagContent
Writes the opening 'label' tag and forces a block tag so that body content is written correctly.- Specified by:
writeTagContentin classAbstractFormTag- Returns:
Tag.EVAL_BODY_INCLUDE- Throws:
JspException
-
getName
Overrides#getName()to always returnnull, because the 'name' attribute is not supported by the 'label' tag.- Overrides:
getNamein classAbstractDataBoundFormElementTag- Returns:
- the value for the HTML '
name' attribute - Throws:
JspException
-
resolveFor
Determine the 'for' attribute value for this tag, autogenerating one if none specified.- Throws:
JspException- See Also:
-
autogenerateFor
Autogenerate the 'for' attribute value for this tag.The default implementation delegates to
AbstractDataBoundFormElementTag.getPropertyPath(), deleting invalid characters (such as "[" or "]").- Throws:
JspException
-
doEndTag
Close the 'label' tag.- Specified by:
doEndTagin interfaceTag- Overrides:
doEndTagin classTagSupport- Throws:
JspException
-
doFinally
public void doFinally()Disposes of theTagWriterinstance.- Specified by:
doFinallyin interfaceTryCatchFinally- Overrides:
doFinallyin classAbstractDataBoundFormElementTag
-