Hi Dimitri,
-- Did you find any solution in GWT for above mentioned problem that would invoke an event when user navigates away from the screen without closing it
On Wednesday, 3 September 2008 05:13:01 UTC-4, buz...@gmail.com wrote:
On Wednesday, 3 September 2008 05:13:01 UTC-4, buz...@gmail.com wrote:
Hello,
Is there a way in GWT to catch Window.onUnload event.
I need that to detect when user navigates away from the page, but does
not close the browser.
I have written a native implementation, but are there any plans to add
Window.addUnloadListener() functionality?
Or am I missing something?
My implementation looked like this () :
public abstract class MeasuringEntryPoint implements EntryPoint {
private static final List onunloadListneners = new ArrayList();
public MeasuringEntryPoint() {
attachOnUnloadListener();
addUnloadListener(new
MeasuringEntryPoint.WindowUnloadListener() {
public void onWindowUnloaded() {
detachOnUnloadListener();
Collection measurements =
MeasurementStorage.retrieveMeasurements();
MeasurementDeliveryGateway.deliver(measurements);
}
});
}
public static void addUnloadListener(WindowUnloadListener
listener) {
onunloadListneners.add(listener);
}
public static void onUnload() {
for (Iterator iterator = onunloadListneners.iterator();
iterator.hasNext();) {
WindowUnloadListener listener = (WindowUnloadListener)
iterator.next();
listener.onWindowUnloaded();
}
}
private native void attachOnUnloadListener() /*-{
$wnd.onunload = function() {
@com.mycoolapp.gwt.client.MeasuringEntryPoint::onUnload( )
();
}
}-*/;
private native void detachOnUnloadListener() /*-{
$wnd.onunload = null
}-*/;
}
Thanks,
Dmitry
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment