How does this work with bean verification messages and i18n in JSF2?

I created a validation file (ValidationMessages.properties) to make i18n possible in my project.

Looks like:

pwtNumber.error=PWT Number error.. 

I defined it in faces-config.xml:

 <message-bundle>com.mycompany.web.i18n.ValidationMessages</message-bundle> 

In my code, I used it as follows:

  @Null(message = "{pwtNumber.error}") public String getPwtNummer() { return pwtNummer; } 

But the problem is that I am not getting the error message, but the key from the properties file. This is the error message I get:

 myForm:pwtNummer: {pwtNumber.error} 

How can I solve it?

+7
source share
1 answer

You mislead the built-in JSF check with the JSR303 bean check.

<message-bundle> should be used to override / specify JSF built-in verification messages, not the JSR303 bean of verification messages. Although you used the correct file name for the JAR303 bean file for validation, ValidationMessages.properties , checking the JSR303 bean, however, also requires that the package file be placed at the root of the class path (thus, without any package in the default package) . Once you have fixed this, remember to delete the invalid <message-bundle> entry.

See also:

+7
source

All Articles