Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hard Refresh in GWT

Using Google Web Toolkit, I'd like to code the equivalent of a hard refresh (control + F5).

I don't believe (or know) if GWT's Window.Location will work.

import com.google.gwt.user.client.Window.Location;

Window.Location = currentPage; // I don't think it'll be hard refresh
like image 446
Kevin Meredith Avatar asked Apr 30 '13 15:04

Kevin Meredith


2 Answers

For reloading the current page you need to call Window.Location.reload() method.

Reloads the current browser window. All GWT state will be lost.

Or you can even specify your own JSNI (below how todo), because by default force reload is false :

  public static native void forceReload() /*-{
      $wnd.location.reload(true);
    }-*/;
like image 68
Jama A. Avatar answered Sep 23 '22 21:09

Jama A.


According to https://developer.mozilla.org/en-US/docs/DOM/window.location#Methods you would need to call window.location.reload(true) to force the reload of the current page.

Unfortunately GWT wraps only the window.location.reload() via Window.Location.reload(), and it is up to the browser to retrieve the page from the cache or from another get. This is done to achieve the most cross-browser solution.

Never tried but you should be able to use the following.

public static native void reload(boolean force) /*-{
  $wnd.location.reload(force);
}-*/;
like image 23
Andrea Boscolo Avatar answered Sep 21 '22 21:09

Andrea Boscolo