assertEquals("mapname1", bw.getPropertyValue("map[\"key1\"].name"));
assertEquals("mapname0", bw.getPropertyValue("map['key2'].name"));
}
public void testIndexedPropertiesWithIndividualCustomEditorForProperty() {
IndexedTestBean bean = new IndexedTestBean(false);
BeanWrapper bw = new BeanWrapperImpl(bean);
bw.registerCustomEditor(String.class, "array[0].name", new PropertyEditorSupport() {
public void setAsText(String text) throws IllegalArgumentException {
setValue("array0" + text);
}
});
bw.registerCustomEditor(String.class, "array[1].name", new PropertyEditorSupport() {
public void setAsText(String text) throws IllegalArgumentException {
setValue("array1" + text);
}
});
bw.registerCustomEditor(String.class, "list[0].name", new PropertyEditorSupport() {
public void setAsText(String text) throws IllegalArgumentException {
setValue("list0" + text);
}
});
bw.registerCustomEditor(String.class, "list[1].name", new PropertyEditorSupport() {
public void setAsText(String text) throws IllegalArgumentException {
setValue("list1" + text);
}
});
bw.registerCustomEditor(String.class, "map[key1].name", new PropertyEditorSupport() {
public void setAsText(String text) throws IllegalArgumentException {
setValue("mapkey1" + text);
}
});
bw.registerCustomEditor(String.class, "map[key2].name", new PropertyEditorSupport() {
public void setAsText(String text) throws IllegalArgumentException {
setValue("mapkey2" + text);
}
});
bean.populate();
TestBean tb0 = bean.getArray()[0];
TestBean tb1 = bean.getArray()[1];
TestBean tb2 = ((TestBean) bean.getList().get(0));
TestBean tb3 = ((TestBean) bean.getList().get(1));
TestBean tb4 = ((TestBean) bean.getMap().get("key1"));
TestBean tb5 = ((TestBean) bean.getMap().get("key2"));
assertEquals("name0", tb0.getName());
assertEquals("name1", tb1.getName());
assertEquals("name2", tb2.getName());
assertEquals("name3", tb3.getName());
assertEquals("name4", tb4.getName());