org.springframework.web.servlet.tags.form
Class OptionWriter
java.lang.Object
org.springframework.web.servlet.tags.form.OptionWriter
final class OptionWriter
- extends Object
Provides supporting functionality to render a list of 'option
'
tags based on some source object. This object can be either an array, a
Collection
or a Map
.
In the first approach you specify an array or Collection
source object
which are used to render the inner 'option
' tags. When using
this approach you specify the name of the property on the objects which
corresponds to the value of the rendered 'option
' and the name
of the property that corresponds to the label. These properties are then used
when rendering each element of the array/Collection
as an 'option
'.
When the either property name is ommitted the name of the Object.toString()
of
the array/Collection
element is used.
Property names are specified as arguments to the constructor.
Using a Map
In the second approach, 'option
' tags are rendered from a source
Map
. The key and value of the entries in the Map
correspond
to the value and label of the rendered 'option
'.
When using any of these approaches, an 'option
' is marked
as 'selected' if its key matches
the value that
is bound to the tag instance.
- Since:
- 2.0
- Author:
- Rob Harrop
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
OptionWriter
public OptionWriter(Object optionSource,
BindStatus bindStatus,
String valueProperty,
String labelProperty,
boolean htmlEscape)
- Creates a new
OptionWriter
for the supplied objectSource
.
- Parameters:
optionSource
- the source of the 'options
'. Cannot be 'null
'.bindStatus
- the BindStatus
for the bound value. Cannot be 'null
'.valueProperty
- the name of the property used to render 'option
' 'values
'. Optional.labelProperty
- the name of the property used to render 'option
' labels. Optional.
writeOptions
public void writeOptions(TagWriter tagWriter)
throws JspException
- Write the '
option
' tags for the configured optionSource
to
the supplied TagWriter
.
- Throws:
JspException
Copyright © 2002-2006 The Spring Framework.