Reputation: 7771
I have a simple form with a <h:message>
next to each <h:inputText>
to display validation messages.
I want a particular field to be a number between 1 and 999999, and this is the validation message to be displayed if the number is not in the correct range. Using this:
<f:validateLongRange minimum="1" maximum="999999"/>
I get the message:
productId: Validation Error: Specified attribute is not between
the expected values of 1 and 999,999.
I got a request to show the number without the comma delimiter, but this comes with the locale that I have in my faces.config
.
At first I though the basic solution of creating a custon validator and that will check whether the submitted value is a string and whether is in the required range, but it seems to me a bit of an overkill.
Is there another way to do it?
Upvotes: 1
Views: 949
Reputation: 666
in which language do you want your validation message to appear?
One collegue recently had to solve what (I think) is your problem: we are italians, italian bundle and italian locale loaded, but all JSF validations messages (not custom ones, for which the locale was correctly set and retrieved) were in English. After looking into JSF jar files, he discovered that properties files from which this validation message is retrieved were simply ... not available in italian! He had to look for an already-(bad)translated property file and to include it in JSF jar file.
Hope it solves your problem too.
Upvotes: 1
Reputation: 5668
If you are using JSF 1.2 you can set an alternative validation message in your input component:
<h:inputText value=".." validatorMessage="Please enter a valid number">
<f:validateLongRange minimum="1" maximum="999999"/>
</h:inputText>
Upvotes: 2