views:

132

answers:

1

Hi all,

I have a custom spring validator which has the following default message:

public @interface FieldMatch {
    String message() default "au.com.xxx.website.FieldMatchValidation";
...

The problem I'm having is that the message code is not being resolved and <form:error...> is simply displaying the code rather than the message (Which is in a properties file which is being used by a ResourceBundleMessageSource).

I've also tried this as

    String message() default "{au.com.xxx.website.FieldMatchValidation}";

Which causes the message source to crash with an exception indicating that it thinks that the "{}" brackets should contain a number because it thinks it's a parameter place holder.

I think that the issue is that the message code is not being seen as a message code and therefore not resolved, but I cannot figure out why.

Any suggestions?

+1  A: 

Ok, figured it out. It seams that this is all being handled by the hibernate validators and they are hard coded to look for a resource file called ValidationMessages.properties. Once I added that and placed the messages in it, everything started working.

Derek Clarkson