On v7, I have a Window that popup with some “wait a moment…” or “retrieving data…”, while this Window block the app, it may be updating all kind of components behind (mostly Grids)
The flow is like this:
Create a Dialog, adding a task (a thread) that will start with the dialog is attached, when the thread finish (in any way, interrupted/canceled by user, etc) the dialog is closed.
This task normally is retrieving data from a backend and updating view, populating grids, while the Dialog is blocking any user input.
I found that in v14 I have to use Dialog, added a progressBar, a label/span for status info, but after Dialog#open()
, nothing is updated, nor the grid behind, the text to be appended in the statusLabel.
I find out that I have to retain an instance of UI at the constructor of the Dialog, because in the any other moment UI.getCurrent()
returns null so I can’t do this inside the Dialog class for example:
`
public class WaitingWindow extends Dialog {
…
…
public void setStatusLabel(String news) {
//this doesn't throw exception, but doesn't update the label neither
ui.access( () -> statusLabel.setText(news));
//when the dialog is about to close, a few milliseconds before the label is updated
}
`
In the “task”, a thread that starts running when the dialog is attached, in the controller side the Grid isn’t upgrade and throws
java.lang.IllegalStateException: Cannot access state in VaadinSession or UI without locking the session.
at com.vaadin.flow.server.VaadinSession.checkHasLock(VaadinSession.java:527)
at com.vaadin.flow.server.VaadinSession.checkHasLock(VaadinSession.java:541)
How did u implement this? is it any Vaadin build-in component that I am not aware of?, instead of wasting lot of time trying to handle session blockings, threads etc etc