user1053031 user1053031 - 1 month ago 16
Java Question

Vaadin. What to do when UI is not attached?

I have the following situation. In my app i update some controls values periodically using Java's TimerTask.
The updation method looks like this:

public void updateDates()
{
if(!myUI.get().isAttached())
return;

myUI.get().access(() -> {
isAsyncUpdate = true;
resetUnmodified();
isAsyncUpdate = false;
myUI.get().push();
});
}


Ok, once the user logs in everything is being updated w/o any problems. Assume that user logs out and then the same user logs in. And after that the isAttached() method return false.
I can't understand why this happens and how to overcome this(
How can I resolve this issue?

Thanks in advance for any help

Answer

It seems i found the roots of the issue. I used a single timer object to handle all the controls. Now i have refactored class to make it use its own timer per control. It seems it resolves the issue. But this solution is not perfect as for me: a single timer is better that many and the work they do it the same actually. But so far i don't know how to resolve this issue in some another way..