I am fairly new to the Spring framework, developing a web application for internal use.
I'd request help explaining to me whether I've missed something.
I've registered several custom property editors using the CustomEditorConfigurer bean factory post-processor.
It *appears* that there is no code that will suck those custom editors into the BeanWrapperImpl that is used by Spring's MVC/web piece ServletDataBinder and, ultimately, the validation piece's DataBinder.
Am I missing something blatantly obvious? I can see that the constructor of BeanWrapperImpl will force-register certain well-defined PropertyEditors, but I can't find anywhere in the code (nor in tracing through with a debugger) where it would pick up the additional registered custom editors that I've defined in my application context.
I added hacked my SimpleFormController's initBinder method to suck up the custom editors from the Context and BeanFactory, and once this occurs, the Binder does work as expected - that is, when binding request parameters, my custom editors are invoked as I'd expect.
My question is - there has to be some way for the default Binder to pick up the custom property editors, as they're around in the BeanFactory for my application context. What's the bit that I'm missing here? Or is it a bug/feature request?Code:ConfigurableApplicationContext cxt = (ConfigurableApplicationContext) getApplicationContext(); AbstractBeanFactory abf = (AbstractBeanFactory) cxt.getBeanFactory(); Map editors = abf.getCustomEditors(); Iterator keySet = editors.keySet().iterator(); while (keySet.hasNext()) { Class className = (Class) keySet.next(); PropertyEditor propEdit = (PropertyEditor) editors.get(className); binder.registerCustomEditor(className, propEdit); }
Thanks in advance - Peter


Reply With Quote