Localization with bean validation in JSF

空扰寡人 提交于 2019-11-30 00:45:30

You should and can not put JSF tags in the message. Also, JSF's own resource bundle won't be used to resolve localized validation messages. JSR303 bean validation is a completely separate API unrelated to JSF.

To internationalize JSR303 bean validation messages, you need to create a separate ValidationMessages.properties file in the classpath root which can be localized by ValidationMessages_xx_XX.properties files.

E.g.

ERVNomView=Your message here

Which is then to be specified with {key} syntax.

@NotEmpty(message="{ERVNomView}")

See also:

For those of you having the same problem as me (the solution given by @BalusC wasn't working with many different properties files for many languages), the thing to do is to name all of the properties files in the following pattern: ValidationMessages_xx.properties

I don't know why, but the pattern ...xx_XX... wasn't working for me.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!