Love this component, but I’m having a little difficulty. Using an old version (1.6.0) since I’m stuck on Vaadin 7.5 for the moment. When I edit an item, even though the value looks updated in the grid, if I edit the same record again, I get an optimistic lock exception, meaning that the record hasn’t updated in the bean associated with the grid, I think.
Here is the relevant code:
crud.getCrudFormFactory().setVisiblePropertyIds(
"rawType", "rawName", "supplierPO", "quantity", "receiveDate");
crud.getCrudFormFactory().setVisiblePropertyIds(
CrudOperation.READ,
"rawType", "rawName", "supplierPO", "quantity", "receiveDate");
crud.getCrudFormFactory().setVisiblePropertyIds(
CrudOperation.ADD,
"rawType", "rawName", "supplierPO", "quantity", "receiveDate");
crud.getCrudFormFactory().setVisiblePropertyIds(
CrudOperation.UPDATE,
"rawType", "rawName", "supplierPO", "quantity", "receiveDate");
crud.getCrudFormFactory().setVisiblePropertyIds(
CrudOperation.DELETE,
"rawType", "rawName", "supplierPO", "quantity", "receiveDate");
crud.getCrudFormFactory().setFieldCreationListener("rawType", field -> {
((TextField) field).addValueChangeListener((Property.ValueChangeEvent event) -> {
field.setValue(event.getProperty().getValue().toString().toUpperCase());
});
});
crud.getCrudFormFactory().setFieldCreationListener("rawName", field -> {
((TextField) field).addValueChangeListener((Property.ValueChangeEvent event) -> {
field.setValue(event.getProperty().getValue().toString().toUpperCase());
});
});
crud.getCrudFormFactory().setFieldCreationListener("supplierPO", field -> {
((TextField) field).addValueChangeListener((Property.ValueChangeEvent event) -> {
field.setValue(event.getProperty().getValue().toString().toUpperCase());
});
});
crud.getCrudFormFactory().setFieldCreationListener("receiveDate", field -> {
((PopupDateField) field).addValueChangeListener((Property.ValueChangeEvent event) -> {
field.setValue((event.getProperty().getValue()));
crud.refreshGrid();
});
});
}
@PostConstruct
public void init() {
// layout configuration
crud.setCrudListener(new CrudListener<PurchaseOrders>() {
@Override
public List<PurchaseOrders> findAll() {
return purchaseOrdersService.getFiltered(filter.getValue());
}
@Override
public PurchaseOrders add(PurchaseOrders po) {
return purchaseOrdersService.save(po);
}
@Override
public PurchaseOrders update(PurchaseOrders po) {
return purchaseOrdersService.update(po);
}
@Override
public void delete(PurchaseOrders po) {
purchaseOrdersService.delete(po);
}
});
filter.addValueChangeListener(e -> crud.refreshGrid());
}
Any insight as to the cause of my problem would be appreciated.