My application (under development) in the background asynchronously communicates with a bunch of other systems and based on the results of that communication it should update corresponding fields in the UI.
Now I ran into an issue that when another thread tries to update the UI I am getting the following exception:
Exception refreshing UI
java.lang.IllegalStateException: Cannot access state in VaadinSession or UI without locking the session.
at com.vaadin.flow.server.VaadinSession.checkHasLock(VaadinSession.java:544)
...
I have to say that this didn’t come totally unexpected, because practically all UI frameworks I have worked with so far know some restrictions as to which thread(s) may handle and update the UI.
My question thus: Can each thread just grab and lock that session mentioned in the error message (if so: how?) or what else is the suggested/best approach or pattern to inform some UI element (in my case a Grid or TreeGrid bound to a couple of beans using a binder) that some value of one of the beans it visualizes has changed and that it thus should update the bean’s visualization? How should another thread trigger such an update without running into the above issue?
I didn’t find anything re. this subject in the vaadin doc’s but maybe I just didn’t come up with the right search terms. Any pointer would be appreciated!