public class

OptionTag

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.OptionTag

Class Overview

JSP tag for rendering an HTML 'option' tag.

Must be used nested inside a SelectTag.

Provides full support for databinding by marking an 'option' as 'selected' if the value matches the value bound to the out SelectTag.

The value property is required and corresponds to the 'value' attribute of the rendered 'option'.

An optional label property can be specified, the value of which corresponds to inner text of the rendered 'option' tag. If no label is specified then the value property will be used when rendering the inner text.

Summary

Constants
String DISPLAY_VALUE_VARIABLE_NAME The name of the JSP variable used to expose the display value for this tag.
String VALUE_VARIABLE_NAME The name of the JSP variable used to expose the value for this 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
OptionTag()
Public Methods
void setDisabled(String disabled)
Set the value of the 'disabled' attribute.
void setLabel(String label)
Set the text body of the rendered HTML <option> tag.
void setValue(Object value)
Set the 'value' attribute of the rendered HTML <option> tag.
Protected Methods
String autogenerateId()
Autogenerate the 'id' attribute value for this tag.
void exposeAttributes()
Called during writeTagContent(TagWriter) allowing subclasses to add any attributes to the javax.servlet.jsp.PageContext as needed.
BindStatus getBindStatus()
Get the BindStatus for this tag.
String getDisabled()
Get the value of the 'disabled' attribute.
String getLabel()
Get the text body of the rendered HTML <option> tag.
Object getValue()
Get the 'value' attribute of the rendered HTML <option> tag.
boolean isDisabled()
Is the current HTML tag disabled?
void onWriteTagContent()
Make sure we are under a 'select' tag before proceeding.
void removeAttributes()
Called by doFinally() allowing subclasses to remove any attributes from the javax.servlet.jsp.PageContext as needed.
void renderDefaultContent(TagWriter tagWriter)
void renderFromBodyContent(BodyContent bodyContent, TagWriter tagWriter)
Render the tag contents based on the supplied BodyContent.
[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 DISPLAY_VALUE_VARIABLE_NAME

The name of the JSP variable used to expose the display value for this tag.

Constant Value: "displayValue"

public static final String VALUE_VARIABLE_NAME

The name of the JSP variable used to expose the value for this tag.

Constant Value: "value"

Public Constructors

public OptionTag ()

Public Methods

public void setDisabled (String disabled)

Set the value of the 'disabled' attribute.

May be a runtime expression.

Parameters
disabled the value of the 'disabled' attribute

public void setLabel (String label)

Set the text body of the rendered HTML <option> tag.

May be a runtime expression.

public void setValue (Object value)

Set the 'value' attribute of the rendered HTML <option> tag.

May be a runtime expression.

Protected Methods

protected String autogenerateId ()

Autogenerate the 'id' attribute value for this tag.

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

Throws
JspException

protected void exposeAttributes ()

Called during writeTagContent(TagWriter) allowing subclasses to add any attributes to the javax.servlet.jsp.PageContext as needed.

Throws
JspException

protected BindStatus getBindStatus ()

Get the BindStatus for this tag.

protected String getDisabled ()

Get the value of the 'disabled' attribute.

protected String getLabel ()

Get the text body of the rendered HTML <option> tag.

protected Object getValue ()

Get the 'value' attribute of the rendered HTML <option> tag.

protected boolean isDisabled ()

Is the current HTML tag disabled?

Returns
  • true if this tag is disabled
Throws
JspException

protected void onWriteTagContent ()

Make sure we are under a 'select' tag before proceeding.

protected void removeAttributes ()

Called by doFinally() allowing subclasses to remove any attributes from the javax.servlet.jsp.PageContext as needed.

protected void renderDefaultContent (TagWriter tagWriter)

Throws
JspException

protected void renderFromBodyContent (BodyContent bodyContent, TagWriter tagWriter)

Render the tag contents based on the supplied BodyContent.

The default implementation simply flushes the BodyContent directly to the output. Subclasses may choose to override this to add additional content to the output.

Throws
JspException