开发者

JSF2 i18n bean validation messages

开发者 https://www.devze.com 2023-01-25 17:03 出处:网络
How can I return a i18n localized bean validation message? For example, in: @Size(min = 1, message = \"{pleaseProvideADescription}\")

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 pro开发者_如何学JAVAvide a...

I'm still getting:

{pleaseProvideADescription}

As validation message in tag

Thanks


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消