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


http://vaadin.com/api/com/vaadin/ui/Window.html#addListener(com.vaadin.ui.Window.CloseListener)

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.

Nice solution, thanks also. :slight_smile: