0
votes

I'm using primefaces and their growl control in order to display validation error messages and I would like to use the required="true" but customize the message for each input component that uses the required="true". I know you can override the default require message and I know you can create a server side check and add a FacesMessage, but can you use required=true and customize the message? Right now it uses the id which doesn't work well for things "First Name"

1
This article "Finetuning validation" may be helpful as well. - BalusC

1 Answers

5
votes

If you mean that the customization of message is changing the content of the required message then,

<h:inputText id="fn" required="true" requiredMessage="Firstname Can not be Blank" label="Firstname" value="#{user.firstname}"/>                           

<h:inputText id="ln" required="true"  requiredMessage="Lastname Can not be Blank" label="Lastname" value="#{user.lastname}"/>

You have to specify the requiredMessage attribute.