Loading...
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.

Product icon
TUTORIAL

Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.

Close Modal Window from within a Form

Peter Czurak
1 decade ago Feb 21, 2010 5:51am
justin Holmes
1 decade ago Feb 21, 2010 2:08pm
Peter Czurak
1 decade ago Feb 22, 2010 6:48am
Artur Signell
1 decade ago Feb 22, 2010 8:06am

There are two types of windows: browser level windows (e.g. main window) and sub windows. Browser level windows are added to and removed from the application. Sub windows are added to and removed from their parent (browser level) window. What you need to do is remove the sub window from its parent window, something like

((Window)window.getParent()).removeWindow(window);
Jouni Koivuviita
1 decade ago Feb 22, 2010 9:12am

Artur Signell:

((Window)window.getParent()).removeWindow(window);

Would someone be so kind and implement the "Window.closeThisBloodyWindowForMeWouldYa()" method and get us rid of having to worry about the parent once and for all!

k thanks! :)

Peter Czurak
1 decade ago Feb 22, 2010 1:25pm
Artur Signell
1 decade ago Feb 22, 2010 1:28pm
Peter Czurak
1 decade ago Feb 22, 2010 2:39pm
vikas jain
1 decade ago Mar 20, 2010 6:28am
Joonas Lehtinen
1 decade ago Mar 22, 2010 5:41am
Anthony Davie
9 years ago Jun 12, 2012 11:46am

I had a slightly different result- your code gave me an error. I have a form, to which I've added a Save and Cancel button beneath inside a modal Window.

((Window) getWindow().getParent()).removeWindow(getWindow());

What worked for me was this (in the button click event handler):

public void onClickSaveNewContent(Button.ClickEvent event)
      {
      ...
      Window win = event.getButton().getWindow() ;
      win.getParent().removeWindow(win) ;
      ...
      }

Hope that helps others.
I agree with Jouni BTW :D

Last updated on Jun, 12th 2012