Hi Jmix Team,
I want to open a dialog (CcrisprocessErrorScreen
) from my main view (CcrisProcess
) after a background task finishes. I am using an event (CcrisProgressEvent
) to communicate back.
In the background task’s done()
method, I publish the event:
uiEventPublisher..publishEventForCurrentUI(new CcrisProgressEvent(this, ...);
And I listen:
@EventListener
protected void onCcrisProgressEvent(CcrisProgressEvent event) {
if (!event.getResult()) {
userSession.setSynNaviContext(synNaviContext);
viewBuilders.view(this, CcrisprocessErrorScreen.class)
.withOpenMode(ViewOpenMode.DIALOG)
.open();
}
}
What happens
When the background task finishes and the event is published, I get the following stack trace:
java.lang.IllegalStateException: No request is available. This method can only be used with an active VaadinServletRequest
at com.vaadin.flow.server.auth.AccessAnnotationChecker.hasAccess(...)
at io.jmix.flowui.sys.UiAccessChecker.isViewPermitted(...)
at ...
I expect that after the background task finishes, the event listener should be able to open the dialog in the main UI without throwing No request is available
.
- Is this the expected behavior because the background task is running outside of a Vaadin request context?
- Is there an official Jmix-recommended pattern for opening a view from a background task completion handler?
Thank you.
Best Regard,
Chee Hao