Jochen
Jochen

Reputation: 1776

How to customize the error message on programmatically created LongRangeValidator?

I created a long range validator but I am not able to find a way to customize the corresponding message text. I am using JSF 2.x and ApacheMyFaces. Thanks in advance.

if ((integerField.getMaximalValue() != null) && (integerField.getMinimalValue() != null)) { // serverside validation required
    long maximum = integerField.getMaximalValue().longValue();
    long minimum = integerField.getMinimalValue().longValue();
    Validator validator = new LongRangeValidator(maximum, minimum);
    inputInteger.addValidator(validator);
}

Upvotes: 0

Views: 173

Answers (1)

BalusC
BalusC

Reputation: 1108547

Use UIInput#setValidatorMessage().

inputInteger.setValidatorMessage("Please enter a value in range");

Upvotes: 1

Related Questions