In order to correctly bind a unique entity ID to an object in a controller I am using a custom property editor (that needs to do a database lookup) that registered using the following beans in the dispatcher servlet context:
Unfortunately the personDao dependency in the registrar is never injected and remains null:Code:<bean class="org.springframework.beans.factory.config.CustomEditorConfigurer"> <property name="propertyEditorRegistrars"> <list> <ref bean="customPropertyEditorRegistrar" /> </list> </property> </bean> <bean id="customPropertyEditorRegistrar" class="CustomPropertyEditorRegistrar" />
The custom property editor is being using in a controller:Code:public class CustomPropertyEditorRegistrar implements PropertyEditorRegistrar { private PersonDao personDao; @Required public void setPersonDao(PersonDao personDao) { this.personDao = personDao; } public void registerCustomEditors(PropertyEditorRegistry registry) { PersonPropertyEditor personPropertyEditor = new PersonPropertyEditor(); personPropertyEditor.setPersonDao(personDao); registry.registerCustomEditor(Person.class, personPropertyEditor); } }
So I'm mixing XML and annotation configuration. I have nothing in my root context. Why is the dependency not getting injected?Code:@InitBinder protected void initBinder(HttpServletRequest request, ServletRequestDataBinder binder) throws Exception { this.customPropertyEditorRegistrar.registerCustomEditors(binder); }


Reply With Quote