spring-projects / spring-framework

Spring Framework
https://spring.io/projects/spring-framework
Apache License 2.0
56.61k stars 38.13k forks source link

WebMvcConfigurationSupport should support Spring MessageSource as JSR 303 message interpolator by default [SPR-9708] #14342

Closed spring-projects-issues closed 10 months ago

spring-projects-issues commented 12 years ago

Simon Wong opened SPR-9708 and commented

Status Quo

WebMvcConfigurationSupport instantiates a LocalValidatorFactoryBean if JSR 303 is supported. However, it does not set the Spring MessageSource as the messageInterpolator by default.

Workaround

Extend WebMvcConfigurationSupport and add the following 2nd statement.

validator = (Validator) BeanUtils.instantiate(clazz);
((LocalValidatorFactoryBean) validator).setValidationMessageSource(messageSource); // messageSource is Autowired

Affects: 3.1 GA, 3.1.1, 3.1.2

Issue Links:

2 votes, 7 watchers

spring-projects-issues commented 12 years ago

Juergen Hoeller commented

The problem here is that setValidationMessageSource relies on non-standard features in Hibernate Validator, even requiring Hibernate Validator 4.1 or higher there. As of Bean Validation 1.1 (coming next year as part of the EE 7 umbrella), we might get a standard variant for customizing message lookup which suggests that we can do it by default then. However, this will be considered within the Spring Framework 3.3 timeline, not within 3.2 anymore.

Juergen

spring-projects-issues commented 10 years ago

Simon Wong commented

Could I know whether Spring 4 support the customized message lookup if Bean Validation 1.1 is in use?

spring-projects-issues commented 10 years ago

Juergen Hoeller commented

Yes, it does - but just against Hibernate Validator 5, I'm afraid. Even as of Bean Validation 1.1, there is still no standard way to define a ResourceBundle for a MessageInterpolator, other than through Hibernate's custom ResourceBundleLocator mechanism...

Juergen