Open KremnevDmitry opened 6 months ago
Currently, it is not possible to use the definition of a specific event type.
Because ui event listeners are passed to the UiEventsManager
as lambda functions.
Such functions will not be able to resolve the type of generic parameter.
GenericApplicationListenerAdapter
won't be able to do this either. See: https://github.com/spring-projects/spring-framework/issues/15303
So the current workaround is the only way.
Environment
Jmix version: 2.2.999-SNAPSHOT
Bug Description
Look at the following methods:
io.jmix.flowui.component.main.JmixUserIndicator#onApplicationEvent
io.jmix.notificationsflowui.component.notificationsindicator.NotificationsIndicator#onApplicationEvent
io.jmix.quartzflowui.view.jobs.JobModelListView#onApplicationEvent
All of them are typed on
ApplicationEvent
. Thus, when a UI event is published, all three listeners are triggered. In the implementation of these listeners, a type check occurs, and if the current event type matches the listener, then the listener processes it.If you change method signatures to a specific event type, you will get an error.
E.g.:
When publishing any UI event, filtering occurs by event type, but it is not correct. See:
io.jmix.flowui.sys.event.UiEventsManager#filterComponentListeners
io.jmix.flowui.sys.event.UiEventsManager#supportsEvent
According to this logic, any event time is suitable. Therefore, when publishing an event in the following method
io.jmix.flowui.sys.event.UiEventsManager#invokeListener
ajava.lang.ClassCastException
error occurs.We need to add proper filtering and change the signature of the listener methods so that they are parameterized by a specific event type.
Sample Project
flowui
,quartz-flowui
,notifications-flowui
to maven localadmin/admin
UserListView
UserSubstitutions
for admin to trigger UiUserSubstitutionsChangedEvent