In case you want to register {@link PropertyEditor} instances, therecommended usage as of Spring 2.0 is to use custom {@link PropertyEditorRegistrar} implementations that in turn register anydesired editor instances on a given {@link org.springframework.beans.PropertyEditorRegistry registry}. Each PropertyEditorRegistrar can register any number of custom editors.
<bean id="customEditorConfigurer" class="org.springframework.beans.factory.config.CustomEditorConfigurer"> <property name="propertyEditorRegistrars"> <list> <bean class="mypackage.MyCustomDateEditorRegistrar"/> <bean class="mypackage.MyObjectEditorRegistrar"/> </list> </property> </bean>
It's perfectly fine to register {@link PropertyEditor} classes viathe {@code customEditors} property. Spring will create fresh instances ofthem for each editing attempt then:
<bean id="customEditorConfigurer" class="org.springframework.beans.factory.config.CustomEditorConfigurer"> <property name="customEditors"> <map> <entry key="java.util.Date" value="mypackage.MyCustomDateEditor"/> <entry key="mypackage.MyObject" value="mypackage.MyObjectEditor"/> </map> </property> </bean>
Note, that you shouldn't register {@link PropertyEditor} bean instances viathe {@code customEditors} property as {@link PropertyEditor}s are stateful and the instances will then have to be synchronized for every editing attempt. In case you need control over the instantiation process of {@link PropertyEditor}s, use a {@link PropertyEditorRegistrar} to registerthem.
Also supports "java.lang.String[]"-style array class names and primitive class names (e.g. "boolean"). Delegates to {@link ClassUtils} for actualclass name resolution.
NOTE: Custom property editors registered with this configurer do not apply to data binding. Custom editors for data binding need to be registered on the {@link org.springframework.validation.DataBinder}: Use a common base class or delegate to common PropertyEditorRegistrar implementations to reuse editor registration there. @author Juergen Hoeller @since 27.02.2004 @see java.beans.PropertyEditor @see org.springframework.beans.PropertyEditorRegistrar @see ConfigurableBeanFactory#addPropertyEditorRegistrar @see ConfigurableBeanFactory#registerCustomEditor @see org.springframework.validation.DataBinder#registerCustomEditor @see org.springframework.web.servlet.mvc.BaseCommandController#setPropertyEditorRegistrars @see org.springframework.web.servlet.mvc.BaseCommandController#initBinder
|
|
|
|