Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I would use the HyperLink and History class. The good thing about the Hyperlink class is, that it sets this token(e.g.#foobar), and all you have to do, is catch the event, that is fired when the value of the token is changed(ValueChangeEvent). In the eventHandler you would then replace the pages.</p> <p>Example: address of welcome Page: www.yourpage.com/#home on this page would be a link to the "browse book"-page, when the link is clicked the new address would be something like this: www.yourpage.com/#browse</p> <p>And here is the code: <pre><code> public class MainEntryPoint implements EntryPoint, ValueChangeHandler { VerticalPanel panel = new VerticalPanel(); Label label=new Label(); public void onModuleLoad() { Hyperlink link1 = new Hyperlink("books", "browse"); Hyperlink link2 = new Hyperlink("user details", "details"); panel.add(link1); panel.add(link2); panel.add(label); RootPanel.get().add(panel); History.addValueChangeHandler(this); //when there is no token, the "home" token is set else changePage() is called. //this is useful if a user has bookmarked a site other than the homepage. if(History.getToken().isEmpty()){ History.newItem("home"); } else { changePage(History.getToken()); } }</p> <pre><code>public void onValueChange(ValueChangeEvent event) { changePage(History.getToken()); } public void changePage(String token) { if(History.getToken().equals("browse")) { label.setText("Here would be some books"); } else if (History.getToken().equals("details")) { label.setText("Here would be the user details"); } else { label.setText("Welcome page"); } } </code></pre> <p>}</pre></code></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload