Basil Bourque
Basil Bourque

Reputation: 339669

Share one set of read-only Table data across many users/sessions/UIs in Vaadin

I have a a set of read-only data to be displayed as a Table in instances of the same Layout across many user sessions. Rather than replicate the data for each user, I'd like to have only a single instance of the data in memory on my Vaadin server.

My data is simple JavaBean objects, in a List, wrapped in a BeanItemContainer.

➤ Is it safe and proper to create a single List (of data beans) in a single BeanItemContainer, and then specify that one BeanItemContainer instance as the backing Container of many Table instances in many UI instances?

The following is my plan for data updated every minute. I assume there is no way to ask for a list of active Layouts across the Vaadin server, so I'll have build my own weak collection.

Is that approach not thread-safe? Perhaps I should make a single concurrent List of JavaBean data objects shared to all the Layouts, where each Layout makes its own BeanItemContainer wrapping the single concurrent List?

Upvotes: 1

Views: 257

Answers (1)

Artur Signell
Artur Signell

Reputation: 1822

The problem with sharing containers is that containers are not stateless. If one user sorts or filters the container, it will at the same time sort or filter the container (and tables) of all other users. Because of this it is not recommended to take this approach.

If you disable sorting and filtering for the components which share the container, it should work more or less the way you describe.

Upvotes: 1

Related Questions