Important Notice - Forums is archived

To simplify things and help our users to be more productive, we have archived the current forum and focus our efforts on helping developers on Stack Overflow. You can post new questions on Stack Overflow or join our Discord channel.

Product icon

Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.

Vaadin 8 Binder

Kareem Jabr
6 years ago Mar 24, 2017 5:29am
Johannes Häyry
6 years ago Mar 24, 2017 7:09am
Kareem Jabr
6 years ago Mar 24, 2017 4:21pm
Nicklas Karlsson
6 years ago Mar 28, 2017 5:51am
Martin Vyšný
5 years ago Jun 24, 2017 5:54pm
Ilia Motornyi
5 years ago Jul 24, 2017 10:14am
C. Berg
5 years ago Aug 11, 2017 2:17pm
Ulrich Maurer
5 years ago Aug 23, 2017 8:11am

I had the same NPE issue with StringToBigDecimalConverter.
The solution of C.Berg doesn't work for me because it doesn't handle numbers in non english format.
The workaround of Martin Vyšný (https://github.com/vaadin/framework/issues/8664) is the best solution because it uses a NumberFormat with the current locale.

In your case it would look as follows:

    .withConverter(new StringToBigDecimalConverter("Price must be in ##.## format"))
    .bind(Item::getPrice, Item::setPrice);

This results in an empty field, if the price is null and returns null, if the field is empty.