Being a true hyperlink, it is also possible for the user to "right-click, open link in new window", which will cause the application to be loaded in a new window at the state specified by the hyperlink.
public class HistoryExample implements EntryPoint, HistoryListener { private Label lbl = new Label(); public void onModuleLoad() { // Create three hyperlinks that change the application's history. Hyperlink link0 = new Hyperlink("link to foo", "foo"); Hyperlink link1 = new Hyperlink("link to bar", "bar"); Hyperlink link2 = new Hyperlink("link to baz", "baz"); // If the application starts with no history token, start it off in the // 'baz' state. String initToken = History.getToken(); if (initToken.length() == 0) initToken = "baz"; // onHistoryChanged() is not called when the application first runs. Call // it now in order to reflect the initial state. onHistoryChanged(initToken); // Add widgets to the root panel. VerticalPanel panel = new VerticalPanel(); panel.add(lbl); panel.add(link0); panel.add(link1); panel.add(link2); RootPanel.get().add(panel); // Add history listener History.addHistoryListener(this); } public void onHistoryChanged(String historyToken) { // This method is called whenever the application's history changes. Set // the label to reflect the current history token. lbl.setText("The current history token is: " + historyToken); } }
Hyperlink() | Creates an empty hyperlink. |
Hyperlink(String, boolean, String) | Creates a hyperlink with its text and target history token specified. |
Hyperlink(String, String) | Creates a hyperlink with its text and target history token specified. |
addClickListener(ClickListener) | Adds a listener interface to receive click events. |
getHTML() | Gets this object's contents as HTML. |
getTargetHistoryToken() | Gets the history token referenced by this hyperlink. |
getText() | Gets this object's text. |
onBrowserEvent(Event) | |
removeClickListener(ClickListener) | Removes a previously added listener interface. |
setHTML(String) | Sets this object's contents via HTML. |
setTargetHistoryToken(String) | Sets the history token referenced by this hyperlink. |
setText(String) | Sets this object's text. |
true
to treat the specified text as html