Class ErrorsTag
- All Implemented Interfaces:
BodyTag,DynamicAttributes,IterationTag,JspTag,Tag,TryCatchFinally,Serializable,EditorAwareTag
<errors> tag renders field errors in an HTML 'span' tag.
Displays errors for either an object or a particular field.
This tag supports three main usage patterns:
- Field only - set '
path' to the field name (or path) - Object errors only - omit '
path' - All errors - set '
path' to '*'
| Attribute | Required? | Runtime Expression? | Description |
|---|---|---|---|
cssClass |
false |
true |
HTML Optional Attribute |
cssStyle |
false |
true |
HTML Optional Attribute |
delimiter |
false |
true |
Delimiter for displaying multiple error messages. Defaults to the br tag. |
dir |
false |
true |
HTML Standard Attribute |
element |
false |
true |
Specifies the HTML element that is used to render the enclosing errors. |
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 |
false |
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, Rick Evans
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe key under which this tag exposes error messages in thepage context scope.static final StringThe HTML 'span' tag.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.BodyTag
EVAL_BODY_BUFFERED, EVAL_BODY_TAGFields 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 StringGet the value for the HTML 'id' attribute.protected voidExposes any bind status error messages underthis keyin thePageContext.PAGE_SCOPE.Return the delimiter to be used between error messages.Get the HTML element must be used to render the error messages.protected StringgetName()Get the value for the HTML 'name' attribute.protected voidRemoves any bind status error messages that were previously stored underthis keyin thePageContext.PAGE_SCOPE.protected voidrenderDefaultContent(TagWriter tagWriter) voidsetDelimiter(String delimiter) Set the delimiter to be used between error messages.voidsetElement(String element) Set the HTML element must be used to render the error messages.protected booleanShould rendering of this tag proceed at all?Methods inherited from class org.springframework.web.servlet.tags.form.AbstractHtmlElementBodyTag
doEndTag, doFinally, doInitBody, flushBufferedBodyContent, onWriteTagContent, renderFromBodyContent, setBodyContent, writeTagContentMethods 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
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, setValueMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface jakarta.servlet.jsp.tagext.BodyTag
doInitBody, setBodyContentMethods inherited from interface jakarta.servlet.jsp.tagext.IterationTag
doAfterBodyMethods inherited from interface jakarta.servlet.jsp.tagext.Tag
doEndTag, doStartTag, getParent, release, setPageContext, setParent
-
Field Details
-
MESSAGES_ATTRIBUTE
The key under which this tag exposes error messages in thepage context scope.- See Also:
-
SPAN_TAG
The HTML 'span' tag.- See Also:
-
-
Constructor Details
-
ErrorsTag
public ErrorsTag()
-
-
Method Details
-
setElement
Set the HTML element must be used to render the error messages.Defaults to an HTML '
<span/>' tag. -
getElement
Get the HTML element must be used to render the error messages. -
setDelimiter
Set the delimiter to be used between error messages.Defaults to an HTML '
<br/>' tag. -
getDelimiter
Return the delimiter to be used between error messages. -
autogenerateId
Get the value for the HTML 'id' attribute.Appends '
.errors' to the value returned byAbstractDataBoundFormElementTag.getPropertyPath()or to the model attribute name if the<form:errors/>tag's 'path' attribute has been omitted.- Overrides:
autogenerateIdin classAbstractDataBoundFormElementTag- Returns:
- the value for the HTML '
id' attribute - Throws:
JspException- See Also:
-
getName
Get the value for the HTML 'name' attribute.Simply returns
nullbecause the 'name' attribute is not a validate attribute for the 'span' element.- Overrides:
getNamein classAbstractDataBoundFormElementTag- Returns:
- the value for the HTML '
name' attribute - Throws:
JspException
-
shouldRender
Should rendering of this tag proceed at all?Only renders output when there are errors for the configured
path.- Overrides:
shouldRenderin classAbstractHtmlElementBodyTag- Returns:
trueonly when there are errors for the configuredpath- Throws:
JspException
-
renderDefaultContent
- Specified by:
renderDefaultContentin classAbstractHtmlElementBodyTag- Throws:
JspException
-
exposeAttributes
Exposes any bind status error messages underthis keyin thePageContext.PAGE_SCOPE.Only called if
shouldRender()returnstrue.- Overrides:
exposeAttributesin classAbstractHtmlElementBodyTag- Throws:
JspException- See Also:
-
removeAttributes
protected void removeAttributes()Removes any bind status error messages that were previously stored underthis keyin thePageContext.PAGE_SCOPE.- Overrides:
removeAttributesin classAbstractHtmlElementBodyTag- See Also:
-