Closed stefanuebe closed 1 week ago
Workaround using Reflection (e.g. with Apache Commons FieldUtils)
try {
KeyMapper<?> keyMapper = (KeyMapper<?>) FieldUtils.readField(this, "keyMapper", true);
keyMapper.setIdentifierGetter(item -> item instanceof HasId ? ((HasId) item).getId() : item);
} catch (Throwable throwable) {
throw new RuntimeException(throwable);
}
I think this could be copy paste error as the regular ComboBox had similar identifier problem as well: https://github.com/vaadin/flow-components/pull/6632/files
Fixed in version 2.0.0
The CBL does not take the data provider's
getId()
method into account nor does it provide any similar possibility to change the way on how values are compared to items. This leads to the issue, that updated beans need to be provided as a fresh set of items to the CBL to allow setting a "similar" instance as a value.This is for instance an issue, when using it in combination with Jpa Repositories, that create new object instances on update operations.
Therefore the request is, that the CBL's internal key mapper either takes the data provider
getId()
method into account or a respective delegation method to the key mapperssetIdentifierGetter
method is provided.Thanks