It seems that registration of custom editors in BeanWrapperImpl
doesn't work as expected (or I'm missing some important point).
Consider the following example:
In this example, in line 5 NullPointerException is thrown (probably
1. SimpleDateFormat dateFormat = new SimpleDateFormat("dd.MM.yyyy");
2. CustomDateEditor dateEditor = new CustomDateEditor(dateFormat, false);
3. Company company = new Company();
4. BeanWrapperImpl bw = new BeanWrapperImpl(company);
5. bw.registerCustomEditor(null, "employees.birthDate", dateEditor);
6. bw.setPropertyValue("employees", new HashMap());
7. bw.setPropertyValue("employees[id1]", new Person());
8. bw.setPropertyValue("employees[id1].birthDate", "10.10.1990");
wrong exception, but this is not important for my point). After some
Spring code inspection, it seems to me that editor registration is
available only on maps (and list) already filled with elements,
which means that you can not define editors upfront. Furthermore,
it seems that even if you setup maps/lists before registration of
editors, and after registration add some more elements, newly added
elements will not be edited via property editors.
Can anybody comment, please? Is there some workaround maybe?