Skip to main content

Null repsentation needed when using converters in Vaadin 8 binder

TextFields in Vaadin8 are no longer allowed to get a null set as value. This usually is no problem unless we use a Converter for the field binding. In that case a null value about to be bound will raise an assertion error. It also won't help if that field is bound with asRequired.

The solution in this case is to use withNullRepresentation before adding the Converter in the binding builder. This adds another converter at first, that turns null values into "something" so the real converter has to actually work.

See

https://github.com/christoph-frick/try-vaadin8/commit/8eee2ce6880b7a3dd4ce1526cf533ef356d3ec50

and

https://github.com/vaadin/framework/issues/8725