|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.springframework.web.servlet.tags.form.OptionWriter
class OptionWriter
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.
Collection:
If you supply an array or Collection source object to render the
inner 'option' tags, you may optionally specify the name of
the property on the objects which corresponds to the value of the
rendered 'option' (i.e., the valueProperty)
and the name of the property that corresponds to the label (i.e.,
the labelProperty). These properties are then used when
rendering each element of the array/Collection as an 'option'.
If either property name is omitted, the value of Object.toString() of
the corresponding array/Collection element is used instead. However,
if the item is an enum, Enum.name() is used as the default value.
Map:
You can alternatively choose to render 'option' tags by
supplying a Map as the source object.
If you omit property names for the value and label:
key of each Map entry will correspond to the
value of the rendered 'option', andvalue of each Map entry will correspond to
the label of the rendered 'option'.If you supply property names for the value and label:
option' will be
retrieved from the valueProperty on the object
corresponding to the key of each Map entry, andoption' will be
retrieved from the labelProperty on the object
corresponding to the value of each Map entry.
constructor.option' is marked as 'selected' if its key
matches the value that is bound to the tag instance.
| Field Summary | |
|---|---|
private BindStatus |
bindStatus
|
private boolean |
htmlEscape
|
private java.lang.String |
labelProperty
|
private java.lang.Object |
optionSource
|
private java.lang.String |
valueProperty
|
| Constructor Summary | |
|---|---|
OptionWriter(java.lang.Object optionSource,
BindStatus bindStatus,
java.lang.String valueProperty,
java.lang.String labelProperty,
boolean htmlEscape)
Creates a new OptionWriter for the supplied objectSource. |
|
| Method Summary | |
|---|---|
private void |
doRenderFromCollection(java.util.Collection optionCollection,
TagWriter tagWriter)
Renders the inner ' option' tags using the supplied Collection of
objects as the source. |
private java.lang.String |
getDisplayString(java.lang.Object value)
Determines the display value of the supplied Object,
HTML-escaped as required. |
protected boolean |
isOptionDisabled()
Determine whether the option fields should be disabled. |
private boolean |
isOptionSelected(java.lang.Object resolvedValue)
Determine whether the supplied values matched the selected value. |
private void |
renderFromArray(TagWriter tagWriter)
Renders the inner ' option' tags using the optionSource. |
private void |
renderFromCollection(TagWriter tagWriter)
Renders the inner ' option' tags using the optionSource. |
private void |
renderFromEnum(TagWriter tagWriter)
Renders the inner ' option' tags using the optionSource. |
private void |
renderFromMap(TagWriter tagWriter)
Renders the inner ' option' tags using the supplied
Map as the source. |
private void |
renderOption(TagWriter tagWriter,
java.lang.Object item,
java.lang.Object value,
java.lang.Object label)
Renders an HTML ' option' with the supplied value and label. |
protected void |
writeCommonAttributes(TagWriter tagWriter)
Writes default attributes configured to the supplied TagWriter. |
void |
writeOptions(TagWriter tagWriter)
Write the ' option' tags for the configured optionSource to
the supplied TagWriter. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
private final java.lang.Object optionSource
private final BindStatus bindStatus
private final java.lang.String valueProperty
private final java.lang.String labelProperty
private final boolean htmlEscape
| Constructor Detail |
|---|
public OptionWriter(java.lang.Object optionSource,
BindStatus bindStatus,
java.lang.String valueProperty,
java.lang.String labelProperty,
boolean htmlEscape)
OptionWriter for the supplied objectSource.
optionSource - the source of the options (never null)bindStatus - the BindStatus for the bound value (never 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)| Method Detail |
|---|
public void writeOptions(TagWriter tagWriter)
throws javax.servlet.jsp.JspException
option' tags for the configured optionSource to
the supplied TagWriter.
javax.servlet.jsp.JspException
private void renderFromArray(TagWriter tagWriter)
throws javax.servlet.jsp.JspException
option' tags using the optionSource.
javax.servlet.jsp.JspExceptiondoRenderFromCollection(java.util.Collection, TagWriter)
private void renderFromMap(TagWriter tagWriter)
throws javax.servlet.jsp.JspException
option' tags using the supplied
Map as the source.
javax.servlet.jsp.JspExceptionrenderOption(TagWriter, Object, Object, Object)
private void renderFromCollection(TagWriter tagWriter)
throws javax.servlet.jsp.JspException
option' tags using the optionSource.
javax.servlet.jsp.JspExceptiondoRenderFromCollection(java.util.Collection, TagWriter)
private void renderFromEnum(TagWriter tagWriter)
throws javax.servlet.jsp.JspException
option' tags using the optionSource.
javax.servlet.jsp.JspExceptiondoRenderFromCollection(java.util.Collection, TagWriter)
private void doRenderFromCollection(java.util.Collection optionCollection,
TagWriter tagWriter)
throws javax.servlet.jsp.JspException
option' tags using the supplied Collection of
objects as the source. The value of the valueProperty field is used
when rendering the 'value' of the 'option' and the value of the
labelProperty property is used when rendering the label.
javax.servlet.jsp.JspException
private void renderOption(TagWriter tagWriter,
java.lang.Object item,
java.lang.Object value,
java.lang.Object label)
throws javax.servlet.jsp.JspException
option' with the supplied value and label. Marks the
value as 'selected' if either the item itself or its value match the bound value.
javax.servlet.jsp.JspExceptionprivate java.lang.String getDisplayString(java.lang.Object value)
Object,
HTML-escaped as required.
private boolean isOptionSelected(java.lang.Object resolvedValue)
SelectedValueComparator.isSelected(org.springframework.web.servlet.support.BindStatus, java.lang.Object).
protected boolean isOptionDisabled()
throws javax.servlet.jsp.JspException
javax.servlet.jsp.JspException
protected void writeCommonAttributes(TagWriter tagWriter)
throws javax.servlet.jsp.JspException
TagWriter.
javax.servlet.jsp.JspException
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||