How to reload the web page in GWT? I want to reload the page after a user logged in the system and then it will show the personal status on top of the page. Any idea how?
Thanks a lot.
How to reload the web page in GWT? I want to reload the page after a user logged in the system and then it will show the personal status on top of the page. Any idea how?
Thanks a lot.
Window.Location.reload()
will reload the page, but I'm pretty sure reloading the page is not what really you want.
You probably just want to refresh certain parts of the page to update once the user logs in.
The reason is, reloading the page will re-download the JavaScript and images on the page, which is a lot of traffic just to refresh the UI.
For problems like these, you could use an event bus... seems very well suited to what you want to do. Your authentication widget could raise an authentication event on the bus, and all widgets on the page that ought to be reacting to this can just pick it up and change themselves.
There's a discussion about it here.
I suggest creating a div specifically for this display area in your HTML page. For example, in your HTML file:
<div id="header"></div>
<div id="userStats"></div>
<div id="content"></div>
... the rest of our page
However you are catching when someone logged in (Database, EventBus, whatever), just update that single panel like so:
RootPanel statsPanel = RootPanel.get("userStats");
statsPanel.clear();
statsPanel.add(new StatsPanel());
Perhaps you create your StatsPanel
using the UiBinder.