I have had following source code:
formLayout = new FormLayout(); binder = new BeanFieldGroup<>(Placement.class); binder.setItemDataSource(this.placement); Field<?> f = binder.buildAndBind("Placement name", "name"); formLayout.addComponent(f); binder.setBuffered(true);
When I tried to execute project, I found out that 'Placement name' field in the form is not editable. So I debugged isEnabled() and isReadOnly() method of the 'f' field. Surprisingly 'isReadOnly()' method returned True all the time.
The cause of the problem was quite simple. I've written following implementation of the 'Placement' entity:
If you're not as stupid as I was, you can see the problem already...yes, there is a setter method for 'name' property, so the framework automatically set the field as read only. Following implementation of Placement entity fixed the problem:public class Placement { private String name; public Placement() { this(""); } public Placement(String name) { this.name = name; } public String getName() { return name; } }
public class Placement { private String name; public Placement() { this(""); } public Placement(String name) { this.name = name; } public String getName() { return name; } public String setName() { this.name=name; } }