Clear validation message

I have one textField, so when I leave the field I run this code:

private void buscarParte(FieldEvents.BlurEvent evt) {
            if (cpf.isValid()) {  

So if I put one invalid value, my textfield with be marked (red line in text and message) but if I back to text and put one valid value, the red line and error message don’t vanish, have one method to clear the error message from one field?


Not sure, what you are doing exactly: Are you clicking somewhere outside the textfield after inserting a valid value? Is your BlurListener run?

After calling isValid() or validate() the error-marker should vanish automatically if the value is indeed valid.

Tobias, I create one customValidator

public class CpfValidatorVaadin implements Validator {
    CPFValidator validaCpf = new CPFValidator();
    public void validate(Object o) throws InvalidValueException {
        if(o != null) {
            try {
            }catch (InvalidStateException i){
                throw new InvalidValueException("CPF inválido");

then I use this validator in my field

cpf.addValidator(new CpfValidatorVaadin());

then I add one blurListener

cpf.addBlurListener(evt -> buscarParte(evt));

So. When I insert one invalid value, and leave the field, the validator validate and return one exception (change the border of my field to red), then I back to this field, and insert one valid value, the red border still when I leave the field.

A similar thing just happened to me. I had a ValueChangeListener which called getConvertedValue() on a Field. Ig the value was not convertable, I got an errormessage that would not go away even after I changed the value to something convertable.

Took me a while to realize that it was actually the notification, that the call to my listener was broken from Vaadin’s view because of the unhandled ConversionException. As soon as I had handled the ConversionException in a try-catch everything worked as expected again. Maybe you are experiencing the same problem as you get an InvalidValueException inside a Listener …