Jeffrey.W.Dong
Jeffrey.W.Dong

Reputation: 1067

How can externalResource communicate with mainWindow in Vaadin

I have a vaadin application running, and now, I have a button, by clicking that, it will open a externalResource (e.g getMainWindow().open(new ExternalResource("http://google.com"), "Google", 800, 600, Window.BORDER_NONE);). This works fine. but how can the main app knows when I close that externalResource window? The thing is I wanna add Oauth to app, and when it's done, user close the window, the app page should be refreshed automatically? If this way doesn't work, is there any other ways solve it? Thanks

Upvotes: 2

Views: 2488

Answers (1)

Ingo Kegel
Ingo Kegel

Reputation: 48005

The tab that is opened with getMainWindow().open(new ExternalResource(...)) is not managed by Vaadin, so you cannot be notified when it is closed.

You can embed a browser frame in your application:

Embedded browser = new Embedded("", new ExternalResource("http://google.com"));
browser.setType(Embedded.TYPE_BROWSER);
main.addComponent(browser);

If you need this in a separate window, add that window to the application (not to the main window) and open it:

addWindow(secondWindow);
main.open(new ExternalResource(secondWindow.getURL()), "_new");

Upvotes: 1

Related Questions