0

We are working with the gwt-java application. In one case i need to reload my browser window in my application, that's why i wanted to use 'Window.Location.reload()' which is not working consistently then i used force reloading of an application which is working in 'Chrome' but continuously reloading window in Firefox and IE(not working properly).

Chrome - Version 40.0.2214.45 beta-m (64-bit) Firefox - 24.0 IE - 11

forceReload():

 private static native void forceReload() /*-{
  $wnd.location.reload(true);
}-*/;

what is the best way to reload browser window?

User
  • 173
  • 1
  • 12
  • Please paint a wider picture of your issue, e.g. your code that (conditionally?) invokes the `forceReload`. – geert3 Jan 09 '15 at 09:25

2 Answers2

0

two options:

1) Window.Location.reload();

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

2) Window.Location.replace("myUrl");

Replaces the current URL with a new one. All GWT state will be lost. In the browser's history, the current URL will be replaced by the new URL.

also, window.location.reload(true) refer here

Something as below

public static native void reload(boolean force) /*-{
  $wnd.location.reload(force);
}-*/;   // by default force reload is false
Ankur Singhal
  • 26,012
  • 16
  • 82
  • 116
0

You mean that you only want your page to reload one time when the condition meet? I edited my answer, and see whether you can add a "dummy flag" to indicate the event/ condition to load it for one time only.

if (YourCondition == true && yourConditionFlag  == true){

    yourConditionFlag = false;
    location.reload(true);
}
薛源少
  • 306
  • 1
  • 6
  • 18
  • yes exactly, but the loading is happening forever even if i have condition like above in firefox and ie. – User Jan 09 '15 at 08:37
  • It would be helpful if you mentioned what is the condition are? some code maybe, see whether the edited answer fix your need? – 薛源少 Jan 09 '15 at 08:57
  • it is our own condition like: if(existingId.equals(newId) == false) { private static native void forceReload() /*-{ $wnd.location.reload(true); }-*/; } – User Jan 09 '15 at 09:05
  • This will very likely not help since after reload all GWT (client side) state is lost. `yourConditionFlag` doesn't survive the reload. – geert3 Jan 09 '15 at 09:24
  • If you can pass the `yourConditionFlag` value to servlet? [Please refer this](http://stackoverflow.com/questions/18472199/access-gwt-post-parameters-via-servlet) – 薛源少 Jan 09 '15 at 09:38