public class

LabelTag

extends AbstractHtmlElementTag
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.LabelTag

Class Overview

Databinding-aware JSP tag for rendering an HTML '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.

Summary

[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
LabelTag()
Public Methods
int doEndTag()
Close the 'label' tag.
void doFinally()
Disposes of the TagWriter instance.
String getFor()
Get the value of the 'id' attribute.
void setFor(String forId)
Set the value of the 'for' attribute.
Protected Methods
String autogenerateFor()
Autogenerate the 'for' attribute value for this tag.
String getName()
Overrides getName() to always return null, because the 'name' attribute is not supported by the 'label' tag.
String resolveFor()
Determine the 'for' attribute value for this tag, autogenerating one if none specified.
int writeTagContent(TagWriter tagWriter)
Writes the opening 'label' tag and forces a block tag so that body content is written correctly.
[Expand]
Inherited Methods
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

Public Constructors

public LabelTag ()

Public Methods

public int doEndTag ()

Close the 'label' tag.

Throws
JspException

public void doFinally ()

Disposes of the TagWriter instance.

public String getFor ()

Get the value of the 'id' attribute.

May be a runtime expression.

public void setFor (String forId)

Set the value of the 'for' attribute.

Defaults to the value of getPath(); may be a runtime expression.

Throws
IllegalArgumentException if the supplied value is null

Protected Methods

protected String autogenerateFor ()

Autogenerate the 'for' attribute value for this tag.

The default implementation delegates to getPropertyPath(), deleting invalid characters (such as "[" or "]").

Throws
JspException

protected String getName ()

Overrides getName() to always return null, because the 'name' attribute is not supported by the 'label' tag.

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

protected String resolveFor ()

Determine the 'for' attribute value for this tag, autogenerating one if none specified.

Throws
JspException

protected int writeTagContent (TagWriter tagWriter)

Writes the opening 'label' tag and forces a block tag so that body content is written correctly.

Returns
  • javax.servlet.jsp.tagext.Tag#EVAL_BODY_INCLUDE
Throws
JspException