Hello,
I am having a problem with registering a custom WebBindingInitializer. I need it because I want @DateTimeFormat on JodaTime DateTime fields in command object to work (shouldn't it work automatically? but it doesn't). So I need to set conversion service. I managed to set it in @InitBinder annotated method in Controller and it works as expected, but I would like to have global setting so I made WebBindingInitializer to do the same logic as @InitBinder:
My spring configuration is like in documentation. I read that using <mvc:annotation-driven> can make a problem but I am not using that tag. I tried to debug and found that initBinder method of CommonWebBindingInitializer is not called at all. This is my configuration:Code:import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.convert.ConversionService; import org.springframework.web.bind.WebDataBinder; import org.springframework.web.bind.support.WebBindingInitializer; import org.springframework.web.context.request.WebRequest; public class CommonWebBindingInitializer implements WebBindingInitializer { @Autowired private ConversionService conversionService; @Override public final void initBinder(final WebDataBinder p_binder, final WebRequest p_request) { p_binder.setConversionService(conversionService); } }
Thank you!HTML Code:<bean id="conversionService" class="org.springframework.format.support.FormattingConversionServiceFactoryBean"/> <bean id="localeChangeInterceptor" class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor"> <property name="paramName" value="language" /> </bean> <bean class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping"> <property name="alwaysUseFullPath" value="true" /> <property name="interceptors"> <list> <ref bean="localeChangeInterceptor" /> <bean class="bla.truc.buc.common.util.web.interceptor.ViewNameResolverInterceptor" /> </list> </property> <property name="order" value="1" /> </bean> <bean class="org.springframework.webflow.mvc.servlet.FlowHandlerMapping"> <property name="flowRegistry" ref="flowRegistry" /> <property name="order" value="2" /> </bean> <bean class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter"> </bean> <bean class="org.springframework.webflow.mvc.servlet.FlowHandlerAdapter"> <property name="flowExecutor" ref="flowExecutor" /> </bean> <mvc:default-servlet-handler /> <bean id="fileDownloadView" class="bla.truc.buc.retail.web.view.FileDownloadView" /> <context:component-scan base-package="bla.truc.buc.retail.web.validator, bla.truc.buc.retail.web.property.editor"/> <bean class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping"> <property name="alwaysUseFullPath" value="true" /> <property name="interceptors"> <list> <ref bean="localeChangeInterceptor" /> </list> </property> </bean> <bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver"> <property name="maxUploadSize" value="5000000" /> </bean> <bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter"> <property name="cacheSeconds" value="0" /> <property name="webBindingInitializer"> <bean class="bla.truc.buc.retail.web.util.CommonWebBindingInitializer" /> </property> </bean


Reply With Quote
