public class

ErrorsTag

extends AbstractHtmlElementBodyTag
java.lang.Object
   ↳ TagSupport
     ↳ org.springframework.web.servlet.tags.RequestContextAwareTag
       ↳ org.springframework.web.servlet.tags.HtmlEscapingAwareTag
         ↳ org.springframework.web.servlet.tags.form.AbstractFormTag
           ↳ org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag
             ↳ org.springframework.web.servlet.tags.form.AbstractHtmlElementTag
               ↳ org.springframework.web.servlet.tags.form.AbstractHtmlElementBodyTag
                 ↳ org.springframework.web.servlet.tags.form.ErrorsTag

Class Overview

Form tag for displaying errors for a particular field or object.

This tag supports three main usage patterns:

  1. Field only - set 'path' to the field name (or path)
  2. Object errors only - omit 'path'
  3. All errors - set 'path' to '*'

Summary

Constants
String MESSAGES_ATTRIBUTE The key under which this tag exposes error messages in the PageContext#PAGE_SCOPE page context scope.
String SPAN_TAG The HTML 'span' tag.
[Expand]
Inherited Constants
From class org.springframework.web.servlet.tags.form.AbstractHtmlElementTag
From class org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag
From class org.springframework.web.servlet.tags.RequestContextAwareTag
[Expand]
Inherited Fields
From class org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag
From class org.springframework.web.servlet.tags.RequestContextAwareTag
Public Constructors
ErrorsTag()
Public Methods
String getDelimiter()
Return the delimiter to be used between error messages.
String getElement()
Get the HTML element must be used to render the error messages.
void setDelimiter(String delimiter)
Set the delimiter to be used between error messages.
void setElement(String element)
Set the HTML element must be used to render the error messages.
Protected Methods
String autogenerateId()
Get the value for the HTML 'id' attribute.
void exposeAttributes()
Exposes any bind status error messages under this key in the PageContext#PAGE_SCOPE.
String getName()
Get the value for the HTML 'name' attribute.
void removeAttributes()
Removes any bind status error messages that were previously stored under this key in the PageContext#PAGE_SCOPE.
void renderDefaultContent(TagWriter tagWriter)
boolean shouldRender()
Should rendering of this tag proceed at all?

Only renders output when there are errors for the configured path.

[Expand]
Inherited Methods
From class org.springframework.web.servlet.tags.form.AbstractHtmlElementBodyTag
From class org.springframework.web.servlet.tags.form.AbstractHtmlElementTag
From class org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag
From class org.springframework.web.servlet.tags.form.AbstractFormTag
From class org.springframework.web.servlet.tags.HtmlEscapingAwareTag
From class org.springframework.web.servlet.tags.RequestContextAwareTag
From class java.lang.Object
From interface org.springframework.web.servlet.tags.EditorAwareTag

Constants

public static final String MESSAGES_ATTRIBUTE

The key under which this tag exposes error messages in the PageContext#PAGE_SCOPE page context scope.

Constant Value: "messages"

public static final String SPAN_TAG

The HTML 'span' tag.

Constant Value: "span"

Public Constructors

public ErrorsTag ()

Public Methods

public String getDelimiter ()

Return the delimiter to be used between error messages.

public String getElement ()

Get the HTML element must be used to render the error messages.

public void setDelimiter (String delimiter)

Set the delimiter to be used between error messages.

Defaults to an HTML '<br/>' tag.

public void setElement (String element)

Set the HTML element must be used to render the error messages.

Defaults to an HTML '<span/>' tag.

Protected Methods

protected String autogenerateId ()

Get the value for the HTML 'id' attribute.

Appends '.errors' to the value returned by getPropertyPath() or to the model attribute name if the <form:errors/> tag's 'path' attribute has been omitted.

Returns
  • the value for the HTML 'id' attribute
Throws
JspException

protected void exposeAttributes ()

Exposes any bind status error messages under this key in the PageContext#PAGE_SCOPE.

Only called if shouldRender() returns true.

Throws
JspException

protected String getName ()

Get the value for the HTML 'name' attribute.

Simply returns null because the 'name' attribute is not a validate attribute for the 'span' element.

Returns
  • the value for the HTML 'name' attribute
Throws
JspException

protected void removeAttributes ()

Removes any bind status error messages that were previously stored under this key in the PageContext#PAGE_SCOPE.

protected void renderDefaultContent (TagWriter tagWriter)

Throws
JspException

protected boolean shouldRender ()

Should rendering of this tag proceed at all?

Only renders output when there are errors for the configured path.

Returns
  • true only when there are errors for the configured path
Throws
JspException