You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Dave Bender <db...@umn.edu> on 2004/09/24 14:47:41 UTC
Getting subset from collection
Is there a utility somewhere in Struts or the Commons that pulls subset of
objects from a collection based on a String array of values?
Here's what I mean: I have a collection of objects that have label and
value fields so I can use them in the Struts multibox tag. Struts returns a
String array of the values that were selected. Now I want to get a
collection of the objects the user selected based on the contents of the
String array. So, they selected item 5, 19 and 23. I'm looking for a
one-step way to pull objects 5, 19 and 23 from a collection of all the
objects.
I've looked at the Collections methods but don't see a way to get anything
but one item from a HashMap. I've looked at BeanUtils, but couldn't find
anything. So, I'm iterating through the collection, which works, but it
seems like such a common routine that it'd already be available. Is it?
Dave