0

BigDecimalField has a nice feature: it allows only digits, "+" and "-" signs, and a decimal separator defined by the current locale ("." or ","). It works fine until someone tries to enter a combination that is not a number or cannot be directly converted to the java BigDecimal type (e.g "123...45.6+++7-89--").
For sach combinations, the validation passes without any warning, and the background business object gets a null value. Field is in the dialog and every time before opening the dialog there is a call to Binder.readBean() method (in order to set the appropriate data for editing), on "save" button in dialog I call Binder.writeBean(). Problem is that the next time I open the dialog, the problematic BigDecimalField still contains an invalid number entered, actually Binder.readBean() stops working for that field.
There is a similar bug with IntegerField which I noticed: IntegerField validation bug.
How can I validate BigDecimalField and avoid this bug? How do i get the BigDecimalField to work again and not keep showing invalid data? Is there a elegant way to catch the NumberFormatException that probably occurs somewhere inside the vaadin api, and proces it i.e. warn the user that he has to enter a valid decimal number. Is there a way to do it via Binder?
I am using Vaadin 23.3.0

saleksand
  • 11
  • 2

1 Answers1

0

Checking format error is not yet by default on. You need to enable it by setting enforceFieldValidation=true in feature flags in src/main/resources/vaadin-featureflags.properties file.

com.vaadin.experimental.enforceFieldValidation=true

See more at: https://github.com/vaadin/platform/issues/3066

Tatu Lund
  • 9,949
  • 1
  • 12
  • 26
  • Unfortunately this is not a solution to the problem, this setting changes absolutely nothing, the component still behaves buggy as described. – saleksand Feb 22 '23 at 12:25