executeJavaScript on subWindow, doesn't work for me

e.g.

public class MyApplication extends Application {
@Override
public void init() {

	Window mainWindow = new Window("test");
			
	Label label = new Label("Main window!!!");
	mainWindow.addComponent(label);		
	mainWindow.executeJavaScript("alert('Main!!')");
	setMainWindow(mainWindow);
	
	Window another = new Window("another");		
	another.setName("another");
	another.executeJavaScript("alert('Hello world')");
	another.addComponent(new Label("I am another window"));				
	addWindow(another);
}

}

Going to the main page is fine, I see the label, I see the alert dialog come up. If I then go to /another I see the new window with its label, but no alert dialog. What am I doing wrong? (I’m a super newbie at Vaadin).

Thanks.

executeJavaScript() only works on browser windows, not subwindows. Unfortunately, the API documentation does not seem to state that.

In general, the class Window is used both for browser windows and for subwindows in Vaadin 6, and some API is only relevant for one or the other of the cases. Vaadin 7 will split these roles so the class Window will only correspond to subwindows, giving a much cleaner API.

Ah, found that code was only getting executed on app start, so I had to ask for /another?restartApplication

Then I got to see the “Hello world” alert window.

As I said, very new to Vaadin, don’t know component lifecycle, going through “Learning Vaadin” book.