Hi all,
I use the EventBus.UIEventBus mechanism from the vaadin-spring-eventbus add-on 14.0.0 for indicating state updates between separated components in my web application (Vaadin 14.4.4). The main view class is annoted with @Route(“”) and @PreserveOnRefresh. All components inside the application are annotated with @UIScope, so in general my application is ready for multi-tab use. Everything works fine so far.
In the following you can see, how an event is fired via UIEventBus. In the second line you see the callback of the onEvent() method in the listener:
2020-12-06 18:45:23,355 | DEBUG | 5EC9D1D25C | o.v.s.e.i.ScopedEventBus$DefaultUIEventBus | Publishing payload [UpdateEvent [commands=[SWITCH_TO_EMULATION]
]] from sender [eu.fhms.msb.mu0.web.view.HeaderView@4b101e12]
on event bus [DefaultUIEventBus[id=620df8a2, eventScope=UI, parentEventBus=DefaultSessionEventBus[id=e1f01b8, eventScope=SESSION, parentEventBus=DefaultApplicationEventBus[id=4843fd0d, eventScope=APPLICATION, parentEventBus=null]
]]] in topic []
2020-12-06 18:45:23,356 | TRACE | 5EC9D1D25C | e.f.m.mu0.web.view.HeaderView | onEvent: Event[scope=UI, eventBus=DefaultUIEventBus[id=620df8a2, eventScope=UI, parentEventBus=DefaultSessionEventBus[id=e1f01b8, eventScope=SESSION, parentEventBus=DefaultApplicationEventBus[id=4843fd0d, eventScope=APPLICATION, parentEventBus=null]
]], ts=1607276723355, source=[eu.fhms.msb.mu0.web.view.HeaderView@4b101e12]
, payload=[UpdateEvent [commands=[SWITCH_TO_EMULATION]
]]]
However, when I refresh the page in the browser, the components keep their states and still work, but with an important difference: the internal event bus “forgets” all its registered listeners. The missing events are a big problem:
2020-12-06 18:46:41,600 | DEBUG | 5EC9D1D25C | o.v.s.e.i.ScopedEventBus$DefaultUIEventBus | Publishing payload [UpdateEvent [commands=[SWITCH_TO_ASSEMBLER]
]] from sender [eu.fhms.msb.mu0.web.view.HeaderView@4b101e12]
on event bus [DefaultUIEventBus[id=620df8a2, eventScope=UI, parentEventBus=DefaultSessionEventBus[id=e1f01b8, eventScope=SESSION, parentEventBus=DefaultApplicationEventBus[id=4843fd0d, eventScope=APPLICATION, parentEventBus=null]
]]] in topic []
2020-12-06 18:46:41,601 | DEBUG | 5EC9D1D25C | o.v.s.e.i.ListenerCollection | No listeners supported event [Event[scope=UI, eventBus=DefaultUIEventBus[id=620df8a2, eventScope=UI, parentEventBus=DefaultSessionEventBus[id=e1f01b8, eventScope=SESSION, parentEventBus=DefaultApplicationEventBus[id=4843fd0d, eventScope=APPLICATION, parentEventBus=null]
]], ts=1607276801601, source=[eu.fhms.msb.mu0.web.view.HeaderView@4b101e12]
, payload=[UpdateEvent [commands=[SWITCH_TO_ASSEMBLER]
]]]]
I tried to re-subscribe the listeners in the onAttach() callback method, which is called after the refresh, but this doesn’t succeed:
protected void onAttach(AttachEvent attachEvent) {
uiEventBus.subscribe(this);
}
Do you have any idea, what’s the problem?
Best regards,
Claus