DM Karthik
DM Karthik

Reputation: 3

Customized message for required="true"

I am using JSF 1.0. I have a text field with required="true". How can I override the default validation error message?

Upvotes: 0

Views: 1722

Answers (1)

BalusC
BalusC

Reputation: 1108632

First create a Messages.properties file in the com.example package with the following content:

javax.faces.component.UIInput.REQUIRED = Please fill out this field.

(the key is specific to validator behind required="true")

Then declare the message properties file in faces-config.xml as message-bundle:

<application>
    <message-bundle>com.example.Messages</message-bundle>
</application>

(without file extension!)

For more message keys, check the JSF specification.

Upvotes: 1

Related Questions