@Override
protected String getMessageId(Validator component) {
// TODO: all messages should be passed to client side using js function RichFaces.csv.addMessage
String messageId;
if (component instanceof DoubleRangeValidator) {
DoubleRangeValidator validator = (DoubleRangeValidator) component;
if (validator.getMaximum() < Double.MAX_VALUE) {
if (validator.getMinimum() > Double.MIN_VALUE) {
messageId = DoubleRangeValidator.NOT_IN_RANGE_MESSAGE_ID;
} else {
messageId = DoubleRangeValidator.MAXIMUM_MESSAGE_ID;
}
} else if (validator.getMinimum() > Double.MIN_VALUE) {
messageId = DoubleRangeValidator.MINIMUM_MESSAGE_ID;
} else {
messageId = DoubleRangeValidator.NOT_IN_RANGE_MESSAGE_ID;// What to use for that case ( no min/max set,
// validator always pass ).
}
} else if (component instanceof LengthValidator) {
LengthValidator validator = (LengthValidator) component;
if (validator.getMaximum() > 0) {
if (validator.getMinimum() > 0) {
messageId = DoubleRangeValidator.NOT_IN_RANGE_MESSAGE_ID;
} else {
messageId = LengthValidator.MAXIMUM_MESSAGE_ID;
}
} else if (validator.getMinimum() > 0) {
messageId = LengthValidator.MINIMUM_MESSAGE_ID;
} else {
messageId = DoubleRangeValidator.NOT_IN_RANGE_MESSAGE_ID;// What to use for that case ( no min/max set,
// validator always pass ).
}
} else if (component instanceof LongRangeValidator) {
LongRangeValidator validator = (LongRangeValidator) component;
if (validator.getMaximum() != LONG_RANGE_VALIDATOR_DEFAULTS.getMaximum()) {
if (validator.getMinimum() != LONG_RANGE_VALIDATOR_DEFAULTS.getMinimum()) {
messageId = DoubleRangeValidator.NOT_IN_RANGE_MESSAGE_ID;
} else {
messageId = LongRangeValidator.MAXIMUM_MESSAGE_ID;
}
} else if (validator.getMinimum() != LONG_RANGE_VALIDATOR_DEFAULTS.getMinimum()) {
messageId = LongRangeValidator.MINIMUM_MESSAGE_ID;
} else {
messageId = DoubleRangeValidator.NOT_IN_RANGE_MESSAGE_ID;// What to use for that case ( no min/max set,
// validator always pass ).
}