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);
grid.addColumn(Pojo::getAmount)
.setEditorBinding(amountEditorBinder);
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?