One Application Multiple Browsers

Hello everyone,

I’m trying to develop a web application that can be accessed from multiple browsers/computers. The application is a data collection console. When the application first starts up it creates a new thread that looks for incoming clients. (These clients are the clients that the application collects data from.) I have been trying everything I can think of. The closest I’ve gotten was an error, com.vaadin.ui.Button already has a parent. I use listeners to update the table when the client connects and whenever new data comes in.

Do any of you have any suggestions on how to go about this or have dealt with this type of situation before?

-Andy Eskridge

Hi there Andy! I’m not really sure what you are looking for as every Vaadin application can be accessed from multiple computers at the same time. Was your point that multiple users should se a live version of the same data with the possibility to modify it? Something more like a
? Please describe a little closer what exactly you want and how it differs from a “plain” Vaadin app, and I might give you some pointers.

Yes. At the moment I cannot get the two web browsers to see the same data. When I start up the second browser it starts up another thread to collect the clients. What I would like is to have the second browser use the same thread that the first browser started.

The end product would hopefully have the table filled with the connected clients, which can be viewed and edited from any browser.

I guess it is kind of like a chat, but there doesn’t need to be any interaction between the two browsers besides seeing the changes made to the clients.

I think the problem might be coming from my BeanItems that I use to fill my table. Each Item has two buttons, an Edit button and a Start button. When I start up two browsers I get an error about a button already having a parent. Is there anything that would make vaadin pitch a fit because two browsers are tying to look at the same data?

You should not share the same Vaadin component instances between different applications/sessions/views - a component instance can only be in one layout at a time.

You also should not share containers directly, as they contain references to their listeners (including e.g. Tables that show their contents). Therefore, a shared container could block the garbage collection of tables (and even big parts of sessions) if the listeners are not unregistered properly for any reason. This is actually not a problem with the Container API per se, but the standard containers cannot not use weak references to listeners as they would cause problems with some clustering solutions.

You could keep the underlying data in some other data structure (not containing component instances), and notify all interested containers through some kind of a message bus or blackboard pattern - there might be a few words about this topic elsewhere on the forum, and there is a thread about the blackboard add-on. Alternatively, you could write a container that manages listeners with weak references, but in that case you should not put component instances in the container.

Thank you very much for the help. I think I have figured out what I am going to do to solve the problem. I’m going to create one container for the server and then each browser is going to have it’s own new container that will be a dumbed down view of the main container. So far the initial results are looking good.

I’m trying to do normal application, but I have a problem, which is similar to yours, but a little different. When I start application from one web browser it works properly. Then I start second web browser(different one), but my first application stops working. I have thread in my app like this:

private static ThreadLocal<DQMainView> currentApplication = null;

in init I do:

		currentApplication = new ThreadLocal<DQMainView>();


public void transactionStart(Application application, Object transactionData) {
		if (application == DQMainView.this) {

	public void transactionEnd(Application application, Object transactionData) {
		if (application == DQMainView.this) {

What’s wrong? Why server didn’t start two different applications?
What happens when I will have my application on normal server and a lot of users would like to start it? Is the result the same as now, when only one instance of application is active?

Also I’ve tried to do this:
but it didn’t work.

OK, problem resolved.
I removed all static components and methods and now it works great for different browsers.