How to create an editor in a Grid for BigDecimal so that I can type it with

So for example I have:

Binder<Pojo> binder;

Binder.Binding<Pojo, BigDecimal> amountEditorBinder = binder.forField(amountTextField)
	.withValidator(DoubleValidator::isValidValue, "Must be valid amount")
	.withConverter(new StringToBigDecimalConverter(new BigDecimal("0"), "Must be an amount"))
	.bind(Pojo::getAmountBigDecimal, AccountEntry::setAmountBigDecimal);

class Pojo
    private BigDecimal amount; // with getters and setters

The problem is that as I’m typing the value can be overwriten as I’m typing. For example if I want to type “12.34” but it takes me more than a second to type the 3 after the period (that is “12.3” then the period is erased and I end up typing “123” which is very annoying. All it takes is for me to look at my sheet of paper as I’m typing and I can’t type in any amounts with cents (numbers after the period) without making a ton of data entry errors because the period gets removed.

I know this is due to the line:

.withConverter(new StringToBigDecimalConverter(new BigDecimal("0"), "Must be an amount"))

but without it I can’t convert the value of the TextField to the value in the Pojo. Is there to fix that?

You could either set the ValueChangeMode of the text field to BLUR, then it will fire the change event only when the field loses its focus or you increase the timeout to something like 10s, so that the user will have a good amount of time to type in its value.

An alternative with a little more effort would be something like a wrapper for the pojo that is used inside the grid as container object. This pojo wrapper could keep the value as a string and also pass the converted value down to the encapsulated pojo. The conversion would then be done inside the wrapper where you would have more control about it plus when to “throw” an error and so on.