Amelia
Amelia

Reputation: 51

How to reload web page in GWT

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.

Upvotes: 5

Views: 28987

Answers (3)

Nick
Nick

Reputation: 1176

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.

Upvotes: 1

Sudhir Jonathan
Sudhir Jonathan

Reputation: 17516

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.

Upvotes: 3

Jason Hall
Jason Hall

Reputation: 20920

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.

Upvotes: 29

Related Questions