Important Notice - Forums is archived
To simplify things and help our users to be more productive, we have archived the current forum and focus our efforts on helping developers on Stack Overflow. You can post new questions on Stack Overflow or join our Discord channel.

Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.
Notify parent window
I have Form which has a data grid when user double clicks on the row it opens up a Modal Window.
My question is how does the Form or the parent of the Modal Window know when the user closed the Modal window so it can refresh the grid?
Thank You.
Peter
Thank you for your help.
I have the following code and the listener works when I click the 'X' in the modal window, but when I close the modal window with this code
((Window) getWindow().getParent()).removeWindow(getWindow());
the Window Close event never fires, how can I detect when the window was closed with either user clicking on the 'X' or the code?
// modal window code
subwindow = new Window("My Modal Window");
subwindow.setModal(true);
//
// create window close listener so we can refresh the grid after user closes the modal window
//
subwindow.addListener(new Window.CloseListener() {
@Override
public void windowClose(CloseEvent e) {
doDataGrid();
}
});
VerticalLayout layout = (VerticalLayout) subwindow.getContent();
layout.setMargin(true);
layout.setSpacing(true);
layout.setSizeUndefined();
MyForm ff = new MyForm();
subwindow.addComponent(ff);
getWindow().addWindow(subwindow);
Removing the window from code will not fire the close event. What you would like to do is to call window.close() which should be public but is currently protected (see #3865). So the options are basically:
- Extend Window, make close public and call it.
- Manually call the close listener after you close the window using removeWindow.