Vaadin 6, how to always include specific components?


I am looking for a way to always include specific components in each of our portlets. This might seem quite obvious but I have a few concerns and would like the opinion of the vaadin community.

First, a little background. We have a fairly large website that include a lot of applications (25+). Every applications are required to have some common widgets (For portlet IPC, handling of browser events, etc…). I am trying to figure the best way to do this.

My initial idea was to systematically include them in a base Application class but then I have many problems. First, since every portlet is implemented differently, I have no control on when the main window is created. This could be worked around without too much hassle though. But then comes another problem: some portlets systematically call getMainWindow.removeAllComponents() everywhere and every time… So even if I add it automatically when the application loads, it can be removed at an unknown point in time.

Another idea would be to subclass Window and change the removeAll() behavior so it does not remove the common components. This would probably work and be really simple to implement but I just feel like it’s not good practice to do this and it would be more of a hack then a real solution.

Then I am out of ideas, what I would like is to be able to add those components outside of the main window, but I don’t think vaadin supports this.

How could I achieve this in a clean way? Any suggestion would be welcome.

Thanks a lot.


For me, this is your fundamental problem. If your portlets tell the main window to remove all the components, but you don’t want to remove all the components, well, I think you have two diametrically opposed intentions - and so there can be no “clean” solution.

I think what I would do is create a new CustomComponentContainer that contains all of the “common” components, and a “real” container. Make CustomComponentContainer implement ComponentContainer and delegate all of the add/remove ComponentContainer methods to the realContainer. I’d then create a “base” application that has a createWindow that uses the CustomComponentContainer as the container for the Window.

HTH a little,



Your solution seems fine. I think we will go that way.

Thank you!