0

BigDecimalRange validator is not working in vaadin version 8.4.3 we tried to change to the latest version of vaadin 8 but the problem persist . Error shows withValidator like renaming the file ,What will be the problem and how can I fix this,Iam trying to change vaadin 7 TextField to vaadin 8 .In v7 it was working fine. Please help

binder.forField(txtAmnt)
.asRequired("This field is mandatory")
.withValidator(new BigDecimalRangeValidator("Enter an amount",BigDecimal.ZERO,new BigDecimal("1000")))
.bind(amount);
Archana
  • 1
  • 2

1 Answers1

0

If your txtAmnt is a TextField you need converter using withConverter as well, StringToBigDecimalConverter. You need to set converter before the withValidator as it assumes BigDecimal type, which is not compatible with String emitted by TextField.

binder.forField(txtAmnt)
    .asRequired("This field is mandatory")
    .withConverter(new StringToBigDecimalConverter("Error converting to 
            BigDecimal")
    .withValidator(new BigDecimalRangeValidator("Enter an 
            amount",BigDecimal.ZERO,new BigDecimal("1000")))
    .bind(amount);
Tatu Lund
  • 9,949
  • 1
  • 12
  • 26