5

How can I return a i18n localized bean validation message?

For example, in:

@Size(min = 1, message = "{pleaseProvideADescription}")
private String description;

Even though I set properties file in faces-config.xml, and I include a pleaseProvideADescription=Please provide a...

I'm still getting:

{pleaseProvideADescription}

As validation message in tag

Thanks

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
icordoba
  • 1,834
  • 2
  • 33
  • 60

1 Answers1

5

Bean validation (JSR-303) is completely unrelated to JSF2 (JSR-314). It's another part of standard Java EE API.

The validation messages have to go in a file named ValidationMessages.properties in the classpath root (which you can internationalize with ValidationMessages_xx_XX.properties files).

Put your custom message there. You don't need to configure anything in JSF's faces-config.xml.

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • 2
    "Bean validation (JSR-303) is completely unrelated to JSF2 (JSR-314). It's another part of standard Java EE API." But which locale would be used in this case - I assume the server locale? This wouldn't be the one which we need... –  Nov 17 '10 at 14:17
  • I followed your hint and added the messages into a property file. Without success. [you can see here](http://stackoverflow.com/questions/12280800/how-does-it-work-with-bean-validation-messages-and-i18n-in-jsf2) – Kayser Sep 05 '12 at 12:39