how to reset the application from a subwindow's button

Hey,

I want to create a WarningDialog which resets the whole Application. I need something like “getApplication().close()”. However, I’ve created the listener’s function in the
“SubWindow” class
like this:

Button ok = new Button("Yeah!");
ok.addStyleName("danger");
ok.addClickListener(new ClickListener() {
 public void buttonClick(ClickEvent event) {
  getApplication().close();
 }
});

This is how I instanciate the dialog in the parent interface:

        deny.addClickListener(new Button.ClickListener() {
            public void buttonClick(ClickEvent event) {
                WarningDialog dialog = new WarningDialog();
                setEnabled(false);
                UI.getCurrent().addWindow(dialog);
            }
        });

If I try to click the supposed ok button I get this error:

java.lang.Error: Unresolved compilation problem: The method getApplication() is undefined for the type new Button.ClickListener(){} Can someone help me out how to reset the application from a subwindow (dialog)?

Thanks! :slight_smile:

Where did you get the getApplication()? It doesn’t exist in Vaadin 7. It’s not in the book page either and…oh, it’s still mentioned in one section.

You probably want to use “Session.getCurrent().close();”.

There’s
some examples here
. If you don’t set the page location, closing the session will restart the application (the session and UIs) immediately.

Thanks :slight_smile:

            Button ok = new Button("Yeah!");
            ok.addStyleName("danger");
            ok.addClickListener(new ClickListener() {
                public void buttonClick(ClickEvent event) {
                    getSession().close();
                }
            });