Issue Details (XML | Word | Printable)

Key: SPR-3612
Type: Improvement Improvement
Status: Open Open
Priority: Major Major
Assignee: Unassigned
Reporter: Pedro Vicente
Votes: 1
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
Spring Framework

Add support for itemLabel and ItemValue using a List of Map in the select tag

Created: 22/Jun/07 11:11 AM   Updated: 30/Aug/07 11:19 AM
Component/s: SpringWEB
Affects Version/s: 2.0.6
Fix Version/s: None

Time Tracking:
Not Specified

Virtual Machine: Sun JVM - 1.4.2
Platform: BEA WebLogic - 8.1


 Description  « Hide
When using the select form we cannot pass the items as a Collection of Map, the items must be a java bean.

For example in this case the countries variable is a List of Map objects

<form:select path="countryCode" items="${countries}" itemLabel="description" itemValue="country_code"></form:select>

The itemLabel "description" and itemValue "country_code" should be the keys of the Map, but the page gives the following error

org.springframework.beans.NotReadablePropertyException: Invalid property 'country_code' of bean class [org.apache.commons.collections.map.ListOrderedMap]: Bean property 'country_code' is not readable or has an invalid getter method: Does the return type of the getter match the parameter type of the setter?
at org.springframework.beans.BeanWrapperImpl.getPropertyValue(BeanWrapperImpl.java:478)
at org.springframework.beans.BeanWrapperImpl.getPropertyValue(BeanWrapperImpl.java:470)
at org.springframework.web.servlet.tags.form.OptionWriter.doRenderFromCollection(OptionWriter.java:150)
at org.springframework.web.servlet.tags.form.OptionWriter.renderFromCollection(OptionWriter.java:136)
at org.springframework.web.servlet.tags.form.OptionWriter.writeOptions(OptionWriter.java:99)
at org.springframework.web.servlet.tags.form.SelectTag.writeTagContent(SelectTag.java:197)
at org.springframework.web.servlet.tags.form.AbstractFormTag.doStartTagInternal(AbstractFormTag.java:82)
at org.springframework.web.servlet.tags.RequestContextAwareTag.doStartTag(RequestContextAwareTag.java:68)
.....

Should the method doRenderFromCollection in the class OptionWriter check to see if the item is a instance of Map and extract the values of the Map instead?

If you agree with this change I can provide a patch.

Thanks


 All   Comments   Work Log   Change History   FishEye   Builds      Sort Order: Ascending order - Click to sort in descending order
Pedro Vicente added a comment - 30/Aug/07 11:19 AM
What do you think of this request?

Shouldn't be possible to use a Collection of Map's?
This will be very helpful when using the queryForList of the SqlTemplate.
Now we must convert the columns to some kind of object for all the lookups.