You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Jerome Jacobsen <je...@gentootech.com> on 2002/05/28 23:09:12 UTC
BeanUtils.populate() throws IllegalArgumentException for indexed String properties.
Maybe I'm misunderstanding BeanUtils.populate, but shouldn't this work????!
public class Company {
private List m_locations = new ArrayList();
public String[] getLocation() {
return (String[])m_locations.toArray(new String[0]);
}
public String getLocation(
int index) {
return (String)m_locations.get(index);
}
public void setLocation(
String[] locations) {
if (locations == null) {
locations = new String[0];
}
m_locations = Arrays.asList(locations);
}
public void setLocation(
int index,
String location) {
m_locations.set(index, location);
}
public static void main(String[] args) throws Exception {
Company gentoo = new Company();
Map properties = new HashMap();
properties.put("location", new String[] {"Blacksburg", "Richmond"});
BeanUtils.populate(gentoo, properties); // throws
IllegalArgumentException!
}
}
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>