I'm using JSR-303 validators (hibernate validation) to validate a bean being bound in one of my controller methods. The validation works, but the output back to the web-layer fails with the following error:
I know this is because one of my custom validation annotations has the following messages property:Code:"java.lang.IllegalArgumentException: can't parse argument number mandatory.field"
It's failing trying to interpolate that message. My question is: can I make use the same messages.properties file I use for other internationalized messages for this purpose?Code:String message() default "{mandatory.field}";
In my spring context, I have a message source:
<bean id="messageSource" class="org.springframework.context.support.Reloada bleResourceBundleMessageSource">
<property name="basename" value="/WEB-INF/messages/messages" />
<property name="cacheSeconds" value="0" />
</bean>
I can't see how to wire this message source into the validation process. I know there is a MessageSourceResourceBundle class that seems to be taking me in the right direction (along with LocaleContextMessageInterpolator and the Hibernate message interpolator) but MessageSourceResourceBundle takes the locale as a constructor arg and I want the message to be resolved on a per-user basis so as to be properly internationalized.
I can't help but think I'm missing something blindingly obvious. Any ideas?


Reply With Quote