Hello!
I am experimenting with server push on a home project and encountered some logs I’ve never seen until bumping vaadin-core to latest. I can reliably reproduce this:
2024-10-02T20:38:49.956+03:00 INFO 20792 --- [nio-8080-exec-1] c.v.f.i.nodefeature.ElementListenerMap : Ignored listener invocation for checked-changed event from the client side for an inert vaadin-checkbox element
2024-10-02T20:38:49.956+03:00 INFO 20792 --- [nio-8080-exec-1] c.v.f.i.nodefeature.ElementListenerMap : Ignored listener invocation for checked-changed event from the client side for an inert vaadin-checkbox element
2024-10-02T20:38:49.956+03:00 INFO 20792 --- [nio-8080-exec-1] c.v.f.i.nodefeature.ElementListenerMap : Ignored listener invocation for indeterminate-changed event from the client side for an inert vaadin-checkbox element
2024-10-02T20:38:49.956+03:00 INFO 20792 --- [nio-8080-exec-1] c.v.f.i.nodefeature.ElementListenerMap : Ignored listener invocation for indeterminate-changed event from the client side for an inert vaadin-checkbox element
I’ll further refer to these 4 as “set of logs”.
For more context, I work with “Device” objects. I have a view which contains a Grid. One of the columns is a component column which contains a checkbox (a command button for the device).
On single click select on a row, a dialog pops up. This dialog contains a number field (used for device calibration) which sends a message via server push on value change event. When this sends a message, all listening UIs (meaning all UIs connected to the app) will start refreshing their items and values (I do this for instant refresh without reloading page):
attachEvent.getUI().access(this::updateView)
// where updateView does this:
grid.setItems(...)
// which creates new checkboxes for all rows again
When the cursor reaches the "attacheEvent.getUI()… " line inside
@Override
protected void onAttach(AttachEvent attachEvent)
All UIs become inert, then the inert status goes downstream until it reaches the checkboxes, then ElementListenerMap logs the lines which I pasted above, from here:
for (DomEventListenerWrapper wrapper : typeListeners) {
if (!isNavigationRequest && inert && !wrapper.allowInert) {
// drop as inert
LoggerFactory.getLogger(ElementListenerMap.class.getName())
.info("Ignored listener invocation for {} event from "
+ "the client side for an inert {} element",
event.getType(), event.getSource().getTag());
continue;
}
I read InertData’s javadoc (and this Server-Side Modality | Advanced Topics | Flow | Vaadin Docs which I’m not actively using as far as I know) that the status is passed down from the parent. I found out the UIs get inert first:
UI.getCurrent().getInternals().getStateTree().getRootNode().isInert() // returns true
I’ve tested with multiple concurrent users (and multiple VaadinSession). When I change the value of the number field, the set of logs appear only once per checkbox, no matter how many listeners are present.
I hope this isn’t breaking anything, as the listeners from Checkbox have NO_OP:
getElement().addPropertyChangeListener("indeterminate", "indeterminate-changed", NO_OP);
getElement().addPropertyChangeListener("checked", "checked-changed", NO_OP);
I’m struggling to figure out why this happens, why the UIs get inert, who makes them inert, if this signals an issue and how to solve this.
I’d really appreciate some insight from you on this topic.