Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JSF2 i18n bean validation messages

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

like image 985
icordoba Avatar asked Nov 17 '10 00:11

icordoba


1 Answers

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.

like image 124
BalusC Avatar answered Sep 28 '22 05:09

BalusC