-
Notifications
You must be signed in to change notification settings - Fork 165
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for browser tab scope #13468
Comments
At least earlier Vaadin used to set |
Yeah, on client-side there's |
Did u found a way to preserve tab data? I have a similar use case (with the difference of using Spring Boot) and can't find a solution. There has to be a default way in Vaadin 14+. Using |
I don't think there's any other way, judging from the fact that vaadin itself uses the window.name+hashmap solution to preserve extended client details |
Is there a reason there can't be a method Otherwise it appears impossible in Vaadin to distinguish browser tabs. Related to that, it's impossible to know whether to preserve or clean up state when Here's why: I've observed the following behavior when reloading tabs:
Side note: You might expect in the So you can see the |
Describe your motivation
I'm building an app which performs bookings; the user can open the app in multiple tabs and launch a booking wizard in every tab. Each wizard instance may have a different booking holder configured, and this booking holder needs to be preserved even when the wizard is navigated away, or when the tab is reloaded via F5.
Describe the solution you'd like
I need to bind certain information (a bean or a string) to a Browser Tab "scope" (using the word "scope" loosely here since I'm not using Spring). The information needs to survive F5 and all sorts of navigation: via UI.navigate(), via the back/forward button and via the user typing a new URL manually into the browser bar. The bean doesn't need to survive session close.
Having an API from Vaadin similar to
BrowserTab.getCurrent().setAttribute("foo", "bar")
would be excellent. The values would survive all sorts of navigations and also F5 page reload. When the tab is closed, the values would be removed and garbage-collected, either immediately or at unspecified time in the future. When the session is closed, the values would be removed and garbage-collected, either immediately or at unspecified time in the future.Alternatively, the UI object could be able to provide a tab ID which would persevere even if UI is destroyed and re-created; that would allow me to create a HashMap from tab ID to my object in VaadinSession. The UI.getId() is null and UI.getUiId() increases with new UI instances and therefore can not be used as tab identifiers.
Describe alternatives you've considered
ComponentUtil.setData(UI.getCurrent())
but this doesn't survive F5.@PreserveOnRefresh
-annotated parent layout which does survive F5 but it doesn't survive browser back/forward button nor user typing a new URL manually.The abovementioned can be replicated with the following example app, just paste these classes into Skeleton Starter for Vaadin 14.8:
The test scenarios:
The text was updated successfully, but these errors were encountered: