subwindow is not working after reloading the page

Hi everybody,

I have a subwindow that is opened by clicken a Button and added by addWindow(subwindow). This works fine even if I reload the page and do nothing but clicking the button. But I have a clicklistener on my layout with a notification and a Blackboard Message (and some more, but only this two lines causing the problem) and only after reloading I am not able to open the subwindow after I clicked on the layout. The second time I click on the button It tells me

If I am using sth like

if (!getMainWindow().getChildWindows().contains(subwindow)) 

the subwindow is simply not added. Therefore I think the subwindow is added to a MainWindow that does not exist or sth. like that. When I am reloading my page, I am doing

getMainWindow().getApplication().close(); in the Window.CloseListener.

If I am clicken on the button twice (or more) at the first time I visit the page, everything works like expected.

Have a nice week :-).

Or what also could be: the subwindow is added to the right mainWindow, but is not shown. I absolutely don’t know what I should do, I’m stuck with this problem since two days…I think to believe that this is a bug of vaadin or sth. like that. Anybodody any suggestions what I could try?

I found the solution.
The problem was that I was creating the mainWindow one time outsite of the methods. But I was adding it every time the init()-method is activated. So the subwindow was added to the “wrong” mainWindow. I don’t know why this problem only appears when the clicklistener of the layout was activated. My easy solution:
I check everytime on the OnRequest if the mainWindow is initialized, if it is not I initialize it (new Window). Every time the CloseListener is activated, I set the mainWindow to null. So for every new User, the mainWindow is newly initialized and the subwindow is added to the new mainWindow.
This works fine :-).