closing multiple UI instances in the same browser

Hi all,

A user can open multiple UI instances in the same browser (e.g. with different authentication).
How can I make each UI instance logout individually?

getUI().getSession().close() will close all UI instances simultaneous.

Regards, Joost

Multi-Tab normally works like this:
If you launch the app in the first tab it creates a session for the browser and a UI instance for the tab.
When you open another tab another UI gets created. This new UI if in the same browser as the last one will be in the same session as the first one.
When you then execute VaadinSession.close() the session + all its UI instances get closed.
To close an individual UI you might have to do: UI.getCurrent().close(); //may not be needed Page.getCurrent().setLocation("/*"); // "/*" might have to be replaced with "/yourappname" where yourappname is your actual app's name
This should in theory close the UI and reload the tab which creates a new (fresh) one.

Thanks Marius, for your answer, but I am afraid it is just theory …

If I just call Page.getCurrent().setLocation nothing seems to happen.
With or without a UI.getCurrent().close().

Also noticed that getUI().getSession().getUIs() (my naive test for multiple browser sessions) is not decremented on close().

Any futher help appreciated,
Regards, Joost

Marius,

The problem must be somewhere in my application (with login, authorisation, shared variables etc.)

I created a minimal test project with the implementation you mentioned and that seems to work properly.

Thanks for your solution, did put me on the right track,
now just debug my own stuff …

Joost