I posted this question java-vaadin-14-detect-user-leave-closes-tab-f5-etc but I think I asked the wrong questions.
I want to limit each signed-in user, to just one (1) active browser tab, or UI for that matter.
Someone told me to use VaadinSession.getCurrent().getUIs()
, but this list is incremented by 1 (or 2 if @Push
is enabled) every time the user refreshes the page. This means I can't check if this list contains more than one (or 2).
I'm lost on this! With native java applications and a built-in login system, I can EASILY limit each user to just one (1) session. It's harder with a browser. Or maybe it isn't?
Asked
Active
Viewed 285 times
1

HoverCatz
- 65
- 1
- 5
- 19
-
I too am curious as to why you want to limit users to a single tab/window. If you explain a bit of your motivation, another solution may be suggested. – Basil Bourque Feb 19 '20 at 02:10
1 Answers
1
You could maybe register a UI init listener which closes all other UIs in the same session whenever a new UI is initialized?
See:
- Tutorial: UIInitListener
- Javadoc
On the other hand, I would also be curious to understand why you want to prevent users from opening multiple tabs.

Basil Bourque
- 303,325
- 100
- 852
- 1,154

Leif Åstrand
- 7,820
- 13
- 19