How to reload a web page in GWT

How to reload a web page in GWT? I want to reload the page after the user logs in, and then displays the personal status at the top of the page. Any idea how?

Many thanks.

+4
source share
3 answers

Window.Location.reload() reload the page, but I'm sure reloading the page is not what you really want.

You probably just want to refresh certain parts of the page to refresh after the user logs in.

The reason is that reloading the page will reload the JavaScript and images on the page, which is a lot of traffic just for updating the user interface.

+29
source

For such problems, you can use the event bus ... seems to be very well suited for what you want to do. An authentication widget can trigger an authentication event on the bus, and all the widgets on the page that should respond to this can simply pick it up and change it themselves.

It is discussed here.

+3
source

I suggest creating a div specifically for this display area on 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 catch when someone is logged in (Database, EventBus, independently), just update this panel as follows:

 RootPanel statsPanel = RootPanel.get("userStats"); statsPanel.clear(); statsPanel.add(new StatsPanel()); 

Perhaps you are creating your StatsPanel using UiBinder.

+1
source

Source: https://habr.com/ru/post/1301176/


All Articles