Same user differnt browser tabs in Vaadin 24

Hi all,

I am opening ‘USER 1’ in same browser tabs(‘Tab 1’,‘Tab 2’). when the Tab 2 is opened(Duplicate Tab), the components on Tab 1 is affected.

I am using @PreserveOnRefresh in the application to preserve the screen.

Can anyone please suggest what could be wrong here?

Thank you.

In what way are components in the other tab affected?

This could be the symptom of accidentally storing some component in a wider Spring or CDI scope (e.g. session scope or singleton) that causes some component instances to be shared between multiple UI instances.

@PreserveOnRefresh is not expected to have any impact in this case since it uses window.name to keep the tabs apart. There might of course be issues if some other script in the application also uses window.name.

I am bit confused here,The actual use case here is, I want to open a Vaadin app in multiple browser tabs so that I can work on 2 tabs in parallel with the same user session.

This is supported by Vaadin. If it doesn’t work in your case, then there’s probably something that can be fixed in application code. I’m trying to understand what exactly might be the problem in your case.

Actually we are using the method mentioned below,

Creating Multi Tab Applications | Community Articles | Framework | Vaadin 8 Docs.

Affected in what way? How does it behave now and how would you expect it to behave instead?

It is removing the components from Tab 1 actually, I am not expecting anything to be refreshed or removed from the Tab 1.

Then I guess there’s something in your application code that makes some component instances shared between UI instances instead of creating a new instance for each UI. This typically happens when you have some component that is used as a Spring or CDI bean that is e.g. session scoped. It can also be the case if you manually store the component instance in the session or e.g. through a static field.

A component instance can only have one parent which means that when you run the code to adds the instance to the new UI, then it is automatically removed from the parent it has in the other UI which causes it to disappear. Creating a new component instance for each UI helps avoid this situation.