How to convert custom error message to check JSR 303 bean?

My question is basically the same as user confirmation for bean verification . However, I can not solve the problem.

Bean class:

public class PersonalInfoBean {
    @Size(min=5, max=55, message="{invalid_name}")
    String name;
    ...
}

I created Message.properties in the package in the src folder of the 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 an error message, and not "Please enter a valid name."

I tested this with JBoss 6 and WebSphere 8 with the same result.

+3
source share
1 answer

JSR 303 Bean JSF. JSR 303 Bean JSF. , JSF .

JSR 303 Bean Validation ValidationMessages.properties, ValidationMessages_xx_XX.properties. .

faces-config.xml. <message-bundle> JSF , required="true", <f:validateRegex>, <f:convertDateTime> ..

+4

All Articles