My question is basically same as Custom validation message for bean validation. However, I can't fix the problem.
The bean class:
public class PersonalInfoBean {
@Size(min=5, max=55, message="{invalid_name}")
String name;
...
}
I created Messages.properties in a package in the src folder of Eclipse project.
invalid_name=Please enter a valid name
I registered the file in faces-config.xml:
<application>
<message-bundle>com.webage.survey.Messages</message-bundle>
</application>
The facelet file has:
<h:inputText value="#{personalInfo.name}" id="name"/> <h:message for="name" style="color: red" /><br/>
When I submit the form, I see only {invalid_name} as error message and not "Please enter a valid name".
I tested this with JBoss 6 and WebSphere 8 with the same result.