/** * Specify a custom Spring MessageSource for resolving validation messages, * instead of relying on JSR-303's default "ValidationMessages.properties" bundle * in the classpath. This may refer to a Spring context's shared "messageSource" bean, * or to some special MessageSource setup for validation purposes only. * <p><b>NOTE:</b> This feature requires Hibernate Validator 4.3 or higher on the classpath. * You may nevertheless use a different validation provider but Hibernate Validator's * {@link ResourceBundleMessageInterpolator} class must be accessible during configuration. * <p>Specify either this property or {@link #setMessageInterpolator "messageInterpolator"}, * not both. If you would like to build a custom MessageInterpolator, consider deriving from * Hibernate Validator's {@link ResourceBundleMessageInterpolator} and passing in a * Spring-based {@code ResourceBundleLocator} when constructing your interpolator. * <p>In order for Hibernate's default validation messages to be resolved still, your * {@link MessageSource} must be configured for optional resolution (usually the default). * In particular, the {@code MessageSource} instance specified here should not apply * {@link org.springframework.context.support.AbstractMessageSource#setUseCodeAsDefaultMessage * "useCodeAsDefaultMessage"} behavior. Please double-check your setup accordingly. * @see ResourceBundleMessageInterpolator */ public void setValidationMessageSource(MessageSource messageSource) { this.messageInterpolator = HibernateValidatorDelegate.buildMessageInterpolator(messageSource); }
/** * Specify a custom Spring MessageSource for resolving validation messages, * instead of relying on JSR-303's default "ValidationMessages.properties" bundle * in the classpath. This may refer to a Spring context's shared "messageSource" bean, * or to some special MessageSource setup for validation purposes only. * <p><b>NOTE:</b> This feature requires Hibernate Validator 4.3 or higher on the classpath. * You may nevertheless use a different validation provider but Hibernate Validator's * {@link ResourceBundleMessageInterpolator} class must be accessible during configuration. * <p>Specify either this property or {@link #setMessageInterpolator "messageInterpolator"}, * not both. If you would like to build a custom MessageInterpolator, consider deriving from * Hibernate Validator's {@link ResourceBundleMessageInterpolator} and passing in a * Spring-based {@code ResourceBundleLocator} when constructing your interpolator. * <p>In order for Hibernate's default validation messages to be resolved still, your * {@link MessageSource} must be configured for optional resolution (usually the default). * In particular, the {@code MessageSource} instance specified here should not apply * {@link org.springframework.context.support.AbstractMessageSource#setUseCodeAsDefaultMessage * "useCodeAsDefaultMessage"} behavior. Please double-check your setup accordingly. * @see ResourceBundleMessageInterpolator */ public void setValidationMessageSource(MessageSource messageSource) { this.messageInterpolator = HibernateValidatorDelegate.buildMessageInterpolator(messageSource); }
/** * Specify a custom Spring MessageSource for resolving validation messages, * instead of relying on JSR-303's default "ValidationMessages.properties" bundle * in the classpath. This may refer to a Spring context's shared "messageSource" bean, * or to some special MessageSource setup for validation purposes only. * <p><b>NOTE:</b> This feature requires Hibernate Validator 4.3 or higher on the classpath. * You may nevertheless use a different validation provider but Hibernate Validator's * {@link ResourceBundleMessageInterpolator} class must be accessible during configuration. * <p>Specify either this property or {@link #setMessageInterpolator "messageInterpolator"}, * not both. If you would like to build a custom MessageInterpolator, consider deriving from * Hibernate Validator's {@link ResourceBundleMessageInterpolator} and passing in a * Spring-based {@code ResourceBundleLocator} when constructing your interpolator. * <p>In order for Hibernate's default validation messages to be resolved still, your * {@link MessageSource} must be configured for optional resolution (usually the default). * In particular, the {@code MessageSource} instance specified here should not apply * {@link org.springframework.context.support.AbstractMessageSource#setUseCodeAsDefaultMessage * "useCodeAsDefaultMessage"} behavior. Please double-check your setup accordingly. * @see ResourceBundleMessageInterpolator */ public void setValidationMessageSource(MessageSource messageSource) { this.messageInterpolator = HibernateValidatorDelegate.buildMessageInterpolator(messageSource); }