Description
When using a Composite, it does not correctly notify the subscribed ItemCountChangeListeners. The addItemCountChangeListener from AbstractDataView subscribes to the instance of Grid, while the fireItemCountEvent inside the DataCommunicator fires the event on the class extending the Composite. As such, no listeners are notified.
A current workaround is calling
ComponentUtil.addListener(this, ItemCountChangeEvent.class, (ComponentEventListener) event -> handleCountEvent();
from the extending class.
Expected outcome
Even when using Grid inside a composite, the ItemCountChangeListeners should be notified.
Minimal reproducible example
public ExampleGrid extends Composite<Grid<TestObject>> {
public ExampleGrid(){
//The below never fires
getContent().getGenericDataView().addItemCountChangeListener(event ->
createFooters(getContent().getGenericDataView().getItems().toList()));
//The below is correctly notified
ComponentUtil.addListener(this, ItemCountChangeEvent.class, (ComponentEventListener) event ->
handleCountEvent();
}
}
Steps to reproduce
- Create a class extending Composite
- In this class, add an ItemCountChangeListener
- Make something change the item count
- Notice that the ItemCountChangeListener is not fired.
Environment
Vaadin version(s): 24.9.10
OS: Windows 11
Browsers
Issue is not browser related
Description
When using a Composite, it does not correctly notify the subscribed ItemCountChangeListeners. The addItemCountChangeListener from AbstractDataView subscribes to the instance of Grid, while the fireItemCountEvent inside the DataCommunicator fires the event on the class extending the Composite. As such, no listeners are notified.
A current workaround is calling
ComponentUtil.addListener(this, ItemCountChangeEvent.class, (ComponentEventListener) event -> handleCountEvent();from the extending class.
Expected outcome
Even when using Grid inside a composite, the ItemCountChangeListeners should be notified.
Minimal reproducible example
Steps to reproduce
Environment
Vaadin version(s): 24.9.10
OS: Windows 11
Browsers
Issue is not browser related