form:select - working, can spring convert to objects based on id?
I have form:select working with returning string id's, and I can take those strings id's and iterate through the original collection and get the original objects - but isn't there some way to get spring mvc to do this automatically?
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Longer Version
I've searched and searched for the answer to this, but to no avail so far (other than "no, it can't").
I have a working multi-select box -
<form:select path="locationsSelectedString" multiple="true">
<form:options items="${contact.locationsAvailable}" itemValue="id" itemLabel="label"/>
</form:select>
If I set the path variable to a String value, I get back a list of id's - for example "location1,location2".
If I set the path variable to a String[] value, I get back an array with the id's - "location1" and "location2"
If I set the path variable to a List<String> value, I get back a List with the id's - "location1" and "location2"
Whatever I used, I can take that list of id's, iterate through the contact.locationsAvailable list -
private List<Location> locationsAvailable;
And get back the original objects.
My question is - isn't there some way to get Spring MVC to do this for me? It seems like all the info is there, and it's a really common case, it seems like there must be some way to get Spring to do this automatically without constantly rewriting the same code...is it out there somewhere?