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.

Vaadin 7 - reliable close detection?

Jon Barrilleaux
9 years ago Jul 03, 2012 1:11am
Leif Åstrand
9 years ago Jul 03, 2012 6:19am
Jon Barrilleaux
9 years ago Jul 03, 2012 5:40pm
s sui
9 years ago Sep 26, 2012 2:34am
Johannes Dahlström
9 years ago Sep 26, 2012 1:39pm
Johannes Dahlström
9 years ago Sep 28, 2012 1:40pm
trobar trobar
9 years ago Oct 02, 2012 4:29pm
Johannes Dahlström
9 years ago Oct 03, 2012 8:56am
trobar trobar
9 years ago Oct 03, 2012 9:23am
Johannes Dahlström
9 years ago Oct 12, 2012 1:27pm
The Vaadin Guy
9 years ago Jan 23, 2013 6:51pm
John Ahlroos
9 years ago Jan 24, 2013 7:14am
Florian Rapp
8 years ago Jun 21, 2013 4:30pm
Marius Reinwald
8 years ago Jun 24, 2013 6:28am
Daniele Casola
8 years ago Jun 28, 2013 8:48am
Henri Sara
8 years ago Jul 01, 2013 11:01am
Daniele Casola
8 years ago Jul 01, 2013 6:46pm
Giovanni Mucciaccia
8 years ago Jul 08, 2013 3:57pm
Marius Reinwald
8 years ago Jul 09, 2013 11:41am
Reuben Sivan
8 years ago Oct 24, 2013 2:55pm
Mark Davidson
8 years ago Jan 24, 2014 8:44pm
Gerhard Sinne
8 years ago Jan 27, 2014 11:10am
Milan Šiler
8 years ago Feb 14, 2014 8:29am
kaleem ansari
7 years ago Sep 16, 2014 2:04pm

did you tried this....

i have written this piece of code in my UI class. and working fine....

this.addDetachListener(new DetachListener() {
            public void detach(DetachEvent event) {
                System.out.println("######### Detached ##########");
            }
        });

        JavaScript.getCurrent().addFunction("aboutToClose", new JavaScriptFunction() {
            @Override
            public void call(org.json.JSONArray arguments)
                    throws org.json.JSONException {
                System.out.println("Window/Tab is Closed.");

                //TODO Call Method to Clean the Resource before window/Tab Close.

            }
        });

         Page.getCurrent().getJavaScript().execute("window.onbeforeunload = function (e) { var e = e || window.event; aboutToClose(); return; };");
Matti Tahvonen
7 years ago Sep 17, 2014 12:23pm
ding pierre
6 years ago Feb 01, 2016 3:15pm
Javier Ortiz Bultron
4 years ago Aug 04, 2017 2:10pm
Anthony Baldarelli
2 years ago Jul 31, 2019 2:33pm
Anthony Baldarelli
2 years ago Jul 31, 2019 7:28pm
David Wall
2 years ago Jul 31, 2019 9:38pm
Anthony Baldarelli
2 years ago Aug 06, 2019 10:14pm
Anthony Baldarelli
2 years ago Aug 08, 2019 1:21am
Anthony Baldarelli
1 year ago Jun 05, 2020 2:19am
Anthony Baldarelli
1 year ago Jun 05, 2020 4:29pm