I have this simple view:
@Route("demo")
public class DemoView extends Div {
public DemoView() {
Binder<Employee> binder = new Binder<>(Employee.class);
TextField nameField = new TextField();
binder.bind(nameField, "name");
add(nameField);
TextField salaryField = new TextField();
binder.forField(salaryField)
.withConverter(new StringToBigDecimalConverter("Not a number!"))
.bind("salary");
add(salaryField);
binder.setBean(new Employee("Kaspar", new BigDecimal("80000"), LocalDate.of(1990, 05, 01)));
Button button = new Button("Klick mich");
button.addClickListener(event -> {
String value = salaryField.getValue();
System.out.println(value);
});
add(button);
}
}
The salary field has a StringToBigDecimalConverter but when salaryField.getValue()
is called a formatted String (e.g. 80,000) is returned. I would assume that getValue should return a BigDecimal.