richim
richim

Reputation: 21

How do we navigate from 1 page to another in GWT

I am building a project in GWT and the project requires navigation from one page to another when a button is clicked. How do I do this? Or should I simply write the entire code in the same class file? I know there has to be a way of navigation.

How should I achieve page navigation in GWT?

Upvotes: 0

Views: 1641

Answers (2)

RAS
RAS

Reputation: 8158

You can do Page navigation through History mechanism of GWT. Here are the steps you should follow:

  1. Add a history string to an iframe of your host page:

  2. Register a ValueChangeHandler that will receive an event of history (page) change. Within this handler you need put a logic that displays the new page. For example, History.addValueChangeHandler(object of subclass of HistoryHandler);

  3. After doing this whenever you need to navigate to another page do the following: History.newItem("history string of your page to be displayed");

Upvotes: 1

Arnaud Denoyelle
Arnaud Denoyelle

Reputation: 31215

You should look at GWT Platform

With this library, you can define places. When the user clicks on a button, you just reveal a new place.

In addition, this framework allows you to handle the lifecycle of your GWT components and do some code splitting : page 1 and page 2 can be compiled in 2 different js so that you only load the one you need.

it is also a (and mainly) a MVP framework, like gwt-presenter.

Upvotes: 2

Related Questions