8
votes

I have a simple JSF form with some validation on the input text. Something like:

<h:inputText id="firstName" value="#{userHandler.user.firstName} required="true" />
<h:message for="firstName" />

Works fine. Except that the error message looks like this:

"j_id786643870_20c27c0a:firstName: Validation Error: Value is required."

How do I tell JSF not to show the element id of the element and just show the text message?

That is, I only want it to say:

"Validation Error: Value is required."

4

4 Answers

10
votes

Either override it by specifying the label attribute:

<h:inputText label="First name" />

Or supply your own validation messages and specify it in <message-bundle> entry in faces-config.xml. Message keys are specified in JSF specification.

See also:

1
votes

In JSF 1.2 you have the provision to display your own error message by using f:validator tag.

Not sure exactly converterMessage or errorMessage

0
votes

I'm using PrimeFaces 6.0, and you can actually set requiredMessage, converterMessage, and validatorMessage on the components themselves, when applicable. From the documentation:

requiredMessage, converterMessage, and validatorMessage in the PrimeFaces 6.0 documentation

Looks like BalusC is finally out of date. :P

0
votes

Add this attribute

requiredMessage="Validation Error: Value is required."