Mahmoud Saleh
Mahmoud Saleh

Reputation: 33605

Cannot override validation error message

i want to override the default password match error message for primefaces, so here's what i did:

under src/main/resources: i created a properties file called messages.properties and added the following keys/values to it:

primefaces.password.INVALID_MATCH = Passwords doesn't match
primefaces.password.INVALID_MATCH_detail = Passwords doesn't match

and in the faces-config, i added the following:

 <application>

   <locale-config>
  <default-locale>en</default-locale>
   </locale-config>
   <message-bundle>
        resources.messages
   </message-bundle>

but it still prints the default message, please advise.

Upvotes: 2

Views: 4494

Answers (2)

ihebiheb
ihebiheb

Reputation: 5173

Why not just adding validatorMessage ?

<p:password id="password1" required="true"   requiredMessage="Password required"
 match="password2" validatorMessage="Passwords doesnt match">
</p:password>

Upvotes: 6

Daniel
Daniel

Reputation: 37051

Note that primefaces got

Messages.properties and *Messages_en.properties*

Try to rename it into Messages.properties with a capital M (best practice) and try adding Messages_en.properties too (cause the one that inside the primefaces jar might override your new Messages.properties)

<message-bundle>
    resources.Messages
</message-bundle>

(if main being part of the package name try adding it before the resources)

Upvotes: 1

Related Questions