public class LabelTag extends AbstractHtmlElementTag
label
' element
that defines text that is associated with a single form element.
The 'for'
attribute is required.
See the "formTags" showcase application that ships with the full Spring distribution for an example of this class in action.
Modifier and Type | Field and Description |
---|---|
private static java.lang.String |
FOR_ATTRIBUTE
The name of the '
for ' attribute. |
private java.lang.String |
forId
The value of the '
for ' attribute. |
private static java.lang.String |
LABEL_TAG
The HTML '
label ' tag. |
private TagWriter |
tagWriter
The
TagWriter instance being used. |
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
Constructor and Description |
---|
LabelTag() |
Modifier and Type | Method and Description |
---|---|
protected java.lang.String |
autogenerateFor()
Autogenerate the '
for ' attribute value for this tag. |
int |
doEndTag()
Close the '
label ' tag. |
void |
doFinally()
Disposes of the
TagWriter instance. |
java.lang.String |
getFor()
Get the value of the '
id ' attribute. |
protected java.lang.String |
getName()
Overrides
getName() to always return null ,
because the 'name ' attribute is not supported by the
'label ' tag. |
protected java.lang.String |
resolveFor()
Determine the '
for ' attribute value for this tag,
autogenerating one if none specified. |
void |
setFor(java.lang.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
isHtmlEscape, setHtmlEscape
doCatch, doStartTag, getRequestContext
private static final java.lang.String LABEL_TAG
label
' tag.private static final java.lang.String FOR_ATTRIBUTE
for
' attribute.private TagWriter tagWriter
TagWriter
instance being used.
Stored so we can close the tag on doEndTag()
.
private java.lang.String forId
for
' attribute.public void setFor(java.lang.String forId)
for
' attribute.
Defaults to the value of AbstractDataBoundFormElementTag.getPath()
; may be a runtime expression.
java.lang.IllegalArgumentException
- if the supplied value is null
public java.lang.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
javax.servlet.jsp.tagext.Tag#EVAL_BODY_INCLUDE
JspException
protected java.lang.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 java.lang.String resolveFor() throws JspException
for
' attribute value for this tag,
autogenerating one if none specified.JspException
getFor()
,
autogenerateFor()
protected java.lang.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.JspException
public void doFinally()
TagWriter
instance.doFinally
in class AbstractDataBoundFormElementTag