开发者

Refresh meta tag in GWT

开发者 https://www.devze.com 2023-01-17 09:09 出处:网络
How 开发者_开发问答can we achieve what the below HTML meta tag can do, in GWT? <meta http-equiv=\"refresh\" content=\"30\" />

How 开发者_开发问答can we achieve what the below HTML meta tag can do, in GWT?

<meta http-equiv="refresh" content="30" />


If you want the browser to automatically refresh every 30 seconds, you can accomplish that with:

new Timer() {
  @Override
  public void run() {
    Window.Location.refresh();
  }
}.schedule(30000); // milliseconds

This is using schedule() instead of scheduleRepeating() because reloading the page like this will cause your GWT code to stop and restart fresh from the beginning. You probably want to avoid this.

I'll be honest, this practice "smells" pretty bad to me. If you give a little more information about why you would want to refresh the page every 30 seconds (thus requiring your GWT code to be reloaded), I can probably give you advice about how to better do what you want to do.

0

精彩评论

暂无评论...
验证码 换一张
取 消