Important Notice - Forums is archived
To simplify things and help our users to be more productive, we have archived the current forum and focus our efforts on helping developers on Stack Overflow. You can post new questions on Stack Overflow or join our Discord channel.

Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.
Windows "piling up"
Hi everyone,
so i have this problem with Windows that sort of pile up. Let me explain better: i have an application with the same exact navigation structure as the dashboard shown on this site, and i use a guava eventbus to send event.
So what happens is this: i have a button in one page that does a procedure, and if it completes correctly it fires up an event. I also have a method registered to that event that show my window (that extends the regular window class). The window i show is a private class member, and i show it like this:
if (window == null) {
window = new VatFoundClientiWindow("Partita iva individuata", vatFoundEvent.getFoundVat());
} else {
UI.getCurrent().removeWindow(window);
window = new VatFoundClientiWindow("Partita iva individuata", vatFoundEvent.getFoundVat());
}
Now, i have 3-4 views that uses this paradigm, BUT they use different events. What happens is this:
1 - I open the window on page A;
2 - I open the window on page B (after navigating there);
3 - I go again to page A and open a window, BUT this time two show instead of one;
4- I go to B again, same procedure, three windows.
And so on. That's why i say that they are piling up, it looks like they remain orphan and get shown.
How could i solve this?
Thanks a lot!
Are you sure each page is not getting the same event, so they all create a window ?
In the code snippet you gave, is the window variable global or local ?
Well, i'm reasonably sure :D I'd like to check to be 100% sure, is there a way of using the debugger to follow the event specifically?
Probably... but you can also do it quite easily showing some event / windows reference (for instance in title)
Ok, so after some more intense debugging i found out that there are "ghost" instances that keep their listeners active and responde to the call...
I say "ghost" because i have a navigator / view paradigm exactly like the dashboard one, but all my views are stateless and cacheless.
So they should allegedly be destroyed and recreated after i change page. I have evidence of the recreation part since when i follow with the debugger the constructor is invoked, but it's like the garbace collector then doesn't collect past views.
Make any sense?