If you use a field derived from AbstractCompositeField CRUD does not recognizes changes.
Please try the attached custom field derived from AbstractCompositeField. This is not what I need (I need an upload field and I developed it but it does not work, same problem as attached field) but this is a minimal case to reproduce the bug. You can try this field inside the Bakery app, for example with the Product. First add a transient field (to avoid touching the DB) to the product:
Class Product {
...
@Transient
private Integer count;
// Getters & Setters - I use Lombok but makes no diff.
public Integer getCount() {
return count;
}
public void setCount(Integer count) {
this.count = count;
}
}
Also import CounterField.java somewhere in your project. This is simply a horizontal layout with a button that increments an integer (attached).
Finally you can add a CounterField to ProductView:
private static BinderCrudEditor<Product> createForm() {
...
CounterField cf = new CounterField(3); // create with init value of 3
FormLayout form = new FormLayout(name, price, cf); // add to the form
...
binder.bind(cf, "count"); // bind it
...
// This is to be sure that the change is fired! log it if you prefer.
binder.addValueChangeListener(new HasValue.ValueChangeListener<HasValue.ValueChangeEvent<?>>() {
@Override
public void valueChanged(HasValue.ValueChangeEvent<?> valueChangeEvent) {
System.out.println("Change event: " + valueChangeEvent + " >-> " + binder.isValid());
}
});
Now open a product, click the button one or more times and notice that the SAVE button does NOT get enabled (at least that is what I would expect - Am I wrong?)
If this is a bug and will take time to be fixed, can you please suggest a bypass so that I can go on with CRUD component, Otherwise I should go back and build one for me for V 14.
Thanks
18509444.java (2.07 KB)