I create on binder and in a specify field I put a validator:
binder.forField(numeroAto).asRequired(Utils.CAMPO_OBRIGATORIO)
.withValidator(valor -> valor == this.indexAto,"Sequencial do ato inválido")
.bind(MatriculaItemRetornoAto::getNumeroAto, MatriculaItemRetornoAto::setNumeroAto);
But when I execute the
binder.validate().isOk()
and the condition are not correctly (Return FALSE)
the binder return false (so its not OK) but the field does not change to the red border.
IntegerField numeroAto = new IntegerField("Numero");
numeroAto.setMinWidth("70px");
my binder instantiation
protected Binder<T> binder = new Binder();
my binder with the field
binder.forField(numeroAto).asRequired(Utils.CAMPO_OBRIGATORIO)
.withValidator(valor -> valor == this.indexAto,"Sequencial do ato inválido")
.bind(MatriculaItemRetornoAto::getNumeroAto, MatriculaItemRetornoAto::setNumeroAto);
my getter and setter are generated by lombok
my field
private Integer numeroAto;
and my validation
return binder.validate().isOk()
like I said, the binder.validate().isOk() return false, and if I loop through the errors return that error I sended at image
at the image the field teste and field Numero are wrong… but only in the field teste the border are red and has a error message. with the NumberField the border dont works
Not related to the problem, but be aware that comparing boxed Integer with == will probably result in unexpected outcomes, if the value is greater than 128