Inconsistency regarding required fields and null handling?

The JavaDoc for AbstractField.isInvalidAllows() states that
“Fields allow invalid values by default. In most cases this is wanted, because the field otherwise visually forget the user input immediately.”

However if you set required to true and the user leaves the field empty, null is not set to the datasource (because setValue(…) in AbstractField does not consider the state of invalidAllows, line 509 in version 7.4.8)

So the user sees an empty field but a value is set in the datasource. This is seems like an inconsistent and unwanted behaviour to me. In our software the leads to the situation, that the user might persist data, he does not see.

Is there something I am missing?

Kind regards
Jan

Same problem. I recently created a bug ticket: https://dev.vaadin.com/ticket/19688

At the moment we have a workaround hack:

  • setInvalidCommited(true) if the field does not hava a converter or the converter does not throw any exception
  • setInvalidCommitted(false) for fields with converter and additionally overwrite the validate method in that field class (e.g. a NumberField overwrited validate and does not check the required-empty-validation)

Ugly and error prone.