-
Notifications
You must be signed in to change notification settings - Fork 38.8k
Description
Shai Yallin opened SPR-7024 and commented
When using a Map as the items values for an OptionWriter-based tag and ommiting the itemValue property (valueProperty is null), OptionWriter still creates BeanWrappers around the map key and values although they are never used.
As a result of that, one is unable to use null as a map key, which may be useful for instance when the map contains enum values as keys and their localized names as values. In this scenario, it may be useful to include null as a map key which represents an empty field value.
affected code:
{{
Object mapKey = entry.getKey();
Object mapValue = entry.getValue();
BeanWrapper mapKeyWrapper = PropertyAccessorFactory.forBeanPropertyAccess(mapKey);
BeanWrapper mapValueWrapper = PropertyAccessorFactory.forBeanPropertyAccess(mapValue);
Object renderValue = (this.valueProperty != null ? mapKeyWrapper.getPropertyValue(this.valueProperty) :
mapKey.toString());
Object renderLabel = (this.labelProperty != null ? mapValueWrapper.getPropertyValue(this.labelProperty) :
mapValue.toString());
renderOption(tagWriter, mapKey, renderValue, renderLabel);
}}
fix suggestion: only create the wrappers if this.valueProperty != null
Affects: 3.0.1
Referenced from: commits a614430