spring-framework / org.springframework.web.servlet.tags.form / OptionTag

OptionTag

open class OptionTag : AbstractHtmlElementBodyTag, BodyTag

The <option> tag renders a single HTML 'option'. Sets 'selected' as appropriate based on bound value.

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.

Attribute Summary Attribute Required? Runtime Expression? Description

cssClass

false

true

HTML Optional Attribute

cssErrorClass

false

true

HTML Optional Attribute. Used when the bound field has errors.

cssStyle

false

true

HTML Optional Attribute

dir

false

true

HTML Standard Attribute

disabled

false

true

HTML Optional Attribute. Setting the value of this attribute to 'true' will disable the HTML element.

htmlEscape

false

true

Enable/disable HTML escaping of rendered values.

id

false

true

HTML Standard Attribute

label

false

true

HTML Optional 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

tabindex

false

true

HTML Standard Attribute

title

false

true

HTML Standard Attribute

value

true

true

HTML Optional Attribute

Author
Rob Harrop

Author
Juergen Hoeller

Since
2.0

Constructors

<init>

OptionTag()

The <option> tag renders a single HTML 'option'. Sets 'selected' as appropriate based on bound value.

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.

Attribute Summary Attribute Required? Runtime Expression? Description

cssClass

false

true

HTML Optional Attribute

cssErrorClass

false

true

HTML Optional Attribute. Used when the bound field has errors.

cssStyle

false

true

HTML Optional Attribute

dir

false

true

HTML Standard Attribute

disabled

false

true

HTML Optional Attribute. Setting the value of this attribute to 'true' will disable the HTML element.

htmlEscape

false

true

Enable/disable HTML escaping of rendered values.

id

false

true

HTML Standard Attribute

label

false

true

HTML Optional 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

tabindex

false

true

HTML Standard Attribute

title

false

true

HTML Standard Attribute

value

true

true

HTML Optional Attribute

Properties

DISPLAY_VALUE_VARIABLE_NAME

static val DISPLAY_VALUE_VARIABLE_NAME: String

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

VALUE_VARIABLE_NAME

static val VALUE_VARIABLE_NAME: String

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

Functions

setDisabled

open fun setDisabled(disabled: Boolean): Unit

Set the value of the 'disabled' attribute.

setLabel

open fun setLabel(label: String): Unit

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

May be a runtime expression.

setValue

open fun setValue(value: Any): Unit

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

Inherited Functions

doEndTag

open fun doEndTag(): Int

If rendering, flush any buffered BodyContent or, if no BodyContent is supplied, render the default content.

doFinally

open fun doFinally(): Unit

Clean up any attributes and stored resources.

doInitBody

open fun doInitBody(): Unit

setBodyContent

open fun setBodyContent(bodyContent: BodyContent): Unit