Vaadin + Holon Platform tips

1.If you’re using Holon Platform PropertyInputForm with a PathProperty like

PathProperty<AddressType> ADDRESS_TYPE = PathProperty.create(Address_.ADDRESS_TYPE, AddressType.class)
        .converter(PropertyValueConverter.enumByName())
        .message("Address Type");

You’ll get an error as NoClassDefFoundError. So, ensure that the PROPERTY_SET contains only the primitive types. To fix the issue, pass a binder like

form = Components.input.form(AddressModel.PROPERTIES)
.bind(AddressModel.ADDRESS_TYPE, Components.input.enumSelect(AddressType.class)
.build())
.build();

2. When you use lazy data loading in vaadin, you will not see the selectAll checkbox at the top because it’s not enabled by default when the data provider is lazy ( since it will fetch all the selected data from the database)

3. When I update the row first time, it works. When I update immediately the same row, I get this error

jakarta.persistence.OptimisticLockException: Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect)

I’ve @version column but still getting this error and @Transactional is also there on the update method.

Probably it is due to I should update the row with the saved data ( the second time it probably contains an old version of the row).

Finally I found, the version number had old value. To fix this, I’ve to move to the JPA default save method because it returns the updated version value automatically. The Holon platform doesn’t return this value so when updating the entity, use JPA save method.

4. There is a difference when using an entity class and a record in Grid.

This will create the columns automatically

grid = new Grid<>(Unit.class, true);

But if you’re using record, this is how it will look, just an empty grid without any columns

public record UnitDto(Long id, String unitName, String shortName) {

}

Grid<UnitDto> grid1 = new Grid<>(UnitDto.class, true);

To fix this issue, you need to add the columns manually one after another like this

grid1.addColumn(UnitDto::id)
.setHeader(Unit_.ID)
.setFlexGrow(0);

5. When you insert a new record and try to refresh the grid using below code, you won’t see them in the grid and no errors thrown.

grid.getLazyDataView().refreshItem(unit);

The right way to refresh the grid in this case is to use

grid.getLazyDataView().refreshAll();

6. When you want to make menuItems checked, follow the below order. Do not alter the order. Otherwise you will get an error as shown below

saveItem.setCheckable(true);
saveItem.setChecked(true);

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.