BeanWrapper does not support objects that are maps/arrays/lists them-selves [SPR-2058] #6751
Labels
has: votes-jira
Issues migrated from JIRA with more than 10 votes at the time of import
in: core
Issues in core modules (aop, beans, core, context, expression)
status: declined
A suggestion or change that we don't feel we should currently apply
type: enhancement
A general enhancement
Alex Antonov opened SPR-2058 and commented
When a BeanWrapper wraps an object that is a map or a collection of sorts, it has trouble retrieving a value using a key property
i.e.
Person p = new Person("John");
Map map = new HashMap();
map.put("key", person);
BeanWrapperImpl wrapper = new BeanWrapperImpl(map);
String name = wrapper.getPropertyValue("[key].name")
This kind of access is very possible when comming from a web-layer using a bind-path of something like [key].name when the top-level object is itself a map.
In this case, when calling errros.rejectValue("[key].name", ...) in the validator, the call throws an exception due to inability to find an object referenced by [key].
Currently a work-around this problem is to subclass a map and provide a getter for every key you might have in the map, so that the path looks like key.name, but
this approach requires a lot of overhead of the getter creation.
11 votes, 9 watchers
The text was updated successfully, but these errors were encountered: