allow for null keys and null values in rendered Map (SPR-7024)
git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@3160 50f2f4bb-b051-0410-bef5-90022cba6387
This commit is contained in:
parent
92bfb2d037
commit
a45ba39399
|
|
@ -157,17 +157,17 @@ class OptionWriter {
|
||||||
* {@link Map} as the source.
|
* {@link Map} as the source.
|
||||||
* @see #renderOption(TagWriter, Object, Object, Object)
|
* @see #renderOption(TagWriter, Object, Object, Object)
|
||||||
*/
|
*/
|
||||||
private void renderFromMap(final TagWriter tagWriter) throws JspException {
|
private void renderFromMap(TagWriter tagWriter) throws JspException {
|
||||||
Map<?, ?> optionMap = (Map) this.optionSource;
|
Map<?, ?> optionMap = (Map) this.optionSource;
|
||||||
for (Map.Entry entry : optionMap.entrySet()) {
|
for (Map.Entry entry : optionMap.entrySet()) {
|
||||||
Object mapKey = entry.getKey();
|
Object mapKey = entry.getKey();
|
||||||
Object mapValue = entry.getValue();
|
Object mapValue = entry.getValue();
|
||||||
BeanWrapper mapKeyWrapper = PropertyAccessorFactory.forBeanPropertyAccess(mapKey);
|
Object renderValue = (this.valueProperty != null ?
|
||||||
BeanWrapper mapValueWrapper = PropertyAccessorFactory.forBeanPropertyAccess(mapValue);
|
PropertyAccessorFactory.forBeanPropertyAccess(mapKey).getPropertyValue(this.valueProperty) :
|
||||||
Object renderValue = (this.valueProperty != null ? mapKeyWrapper.getPropertyValue(this.valueProperty) :
|
mapKey);
|
||||||
mapKey.toString());
|
Object renderLabel = (this.labelProperty != null ?
|
||||||
Object renderLabel = (this.labelProperty != null ? mapValueWrapper.getPropertyValue(this.labelProperty) :
|
PropertyAccessorFactory.forBeanPropertyAccess(mapValue).getPropertyValue(this.labelProperty) :
|
||||||
mapValue.toString());
|
mapValue);
|
||||||
renderOption(tagWriter, mapKey, renderValue, renderLabel);
|
renderOption(tagWriter, mapKey, renderValue, renderLabel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -184,7 +184,7 @@ class OptionWriter {
|
||||||
* Renders the inner '<code>option</code>' tags using the {@link #optionSource}.
|
* Renders the inner '<code>option</code>' tags using the {@link #optionSource}.
|
||||||
* @see #doRenderFromCollection(java.util.Collection, TagWriter)
|
* @see #doRenderFromCollection(java.util.Collection, TagWriter)
|
||||||
*/
|
*/
|
||||||
private void renderFromEnum(final TagWriter tagWriter) throws JspException {
|
private void renderFromEnum(TagWriter tagWriter) throws JspException {
|
||||||
doRenderFromCollection(CollectionUtils.arrayToList(((Class) this.optionSource).getEnumConstants()), tagWriter);
|
doRenderFromCollection(CollectionUtils.arrayToList(((Class) this.optionSource).getEnumConstants()), tagWriter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue