TextField textField = new TextField("BigDecimal field");
textField.setImmediate(true);
textField.setValue("12");
formLayout.addComponent(textField);
final FieldGroup fieldGroup = new FieldGroup(beanItem);
fieldGroup.bind(textField, "decimal");
Button setValue = new Button("Set value to 15,2", new ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
((TextField) fieldGroup.getField("decimal")).setValue("15,2");
}
});
Button button = new Button("Commit");
button.addClickListener(new Button.ClickListener() {
@Override
public void buttonClick(Button.ClickEvent event) {
try {
fieldGroup.commit();
log("Commit ok. Property value: "
+ fieldGroup.getItemDataSource()
.getItemProperty("decimal").getValue());
} catch (FieldGroup.CommitException e) {
log("Commit failed: " + e.getMessage());
}
}