Clearing error indicator?

Hello!
Quick question: how to clear error indicator?
Manuals says "
something
.setComponentError(null)"
and it promises to remove exclamation mark and the message. But for some reasons it chronically does not works for me on Form object: indicator is still there and shows error message in the Form.

Normally, I basically doing this way:

public void hide() {
    AbstractField[] fields = new AbstractField[]
{this.someField, this.someOtherField, this.andSoOnFields};
    for (int j = 0; j < fields.length; j++) {
        fields[j]
.setComponentError(null);
    }
    this.form.setComponentError(null);

    // do some other stuff on window hide etc.
}

Now, when after I closed window.hide() and then re-opened it back window.show() — error is still there. Why? Do I need refresh something? Maybe there is only defined sequence when “setComponentError” method actually works? Because if I just call it — it does not affects my form at all. Or I am calling wrong method? What else then?

I mean, to remove the message from the form, I call “setValidationVisible”, which is turned to True on validation error automatically. But it rather sounds like a workaround. Is it actually a correct behavior when I said “null” to component error and it still there? In fact, form error message is indeed null, so what is shown to the user on the form is not a component error message, but validation error message. OK, why do I need component error message in the form then? — it is quite confusing to me from API point of view.

Vaadin version is 6.3.4.

Thanks! :slight_smile:

An old thread, but this might also help others:

A Form hides the validation area by default when you create one, but makes it visible when you commit the form (based on validationVisibleOnCommit). Reusing the form after this, it remembers that its validation area should be visible, and validates the empty form, where e.g. required fields often cause errors.

The solution:


form.setComponentError(null);
form.setValidationVisible(false);

The area is re-displayed on next commit unless you use setValidationVisibleOnCommit(false).

This is not very intuitive nor well documented, and needs to be improved (like many other things about forms) in Vaadin 7.

Thanks, Henri.

Well, I understand why, but API is just not really clear. To me it seems like
setComponenError(null)
was just like “blindly” acquired, so it just works to an object-level. At the end, actually we do have two error slots on a form. But I would probably suggest to hide error stuff once it is called to null by
setComponentError
at form level, and
setValidationVisible
method should just go away from the API list. It is not needed, because we defined validators, hence form suppose to show errors.

And also would be nice to add a method like
.flushComponentsError
at form level, so it will “recursively”
setComponentError
to null at every component.