|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.google.gwt.user.client.ui.UIObject
com.google.gwt.user.client.ui.Widget
com.google.gwt.user.client.ui.Hyperlink
public class Hyperlink
A widget that serves as an "internal" hyperlink. That is, it is a link to
another state of the running application. When clicked, it will create a new
history frame using History.newItem(java.lang.String)
, but
without reloading the page.
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); } }
Constructor Summary | |
---|---|
Hyperlink()
Creates an empty hyperlink. |
|
Hyperlink(java.lang.String text,
boolean asHTML,
java.lang.String targetHistoryToken)
Creates a hyperlink with its text and target history token specified. |
|
Hyperlink(java.lang.String text,
java.lang.String targetHistoryToken)
Creates a hyperlink with its text and target history token specified. |
Method Summary | |
---|---|
void |
addClickListener(ClickListener listener)
Adds a listener interface to receive click events. |
java.lang.String |
getHTML()
Gets this object's contents as HTML. |
java.lang.String |
getTargetHistoryToken()
Gets the history token referenced by this hyperlink. |
java.lang.String |
getText()
Gets this object's text. |
void |
onBrowserEvent(Event event)
Fired whenever a browser event is received. |
void |
removeClickListener(ClickListener listener)
Removes a previously added listener interface. |
void |
setHTML(java.lang.String html)
Sets this object's contents via HTML. |
void |
setTargetHistoryToken(java.lang.String targetHistoryToken)
Sets the history token referenced by this hyperlink. |
void |
setText(java.lang.String text)
Sets this object's text. |
Methods inherited from class com.google.gwt.user.client.ui.Widget |
---|
doAttachChildren, doDetachChildren, getParent, isAttached, onAttach, onDetach, onLoad, onUnload, removeFromParent, setElement |
Methods inherited from class com.google.gwt.user.client.ui.UIObject |
---|
addStyleDependentName, addStyleName, getAbsoluteLeft, getAbsoluteTop, getElement, getOffsetHeight, getOffsetWidth, getStyleElement, getStyleName, getStyleName, getStylePrimaryName, getStylePrimaryName, getTitle, isVisible, isVisible, removeStyleDependentName, removeStyleName, setHeight, setPixelSize, setSize, setStyleName, setStyleName, setStyleName, setStylePrimaryName, setStylePrimaryName, setTitle, setVisible, setVisible, setWidth, sinkEvents, toString, unsinkEvents |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public Hyperlink()
public Hyperlink(java.lang.String text, boolean asHTML, java.lang.String targetHistoryToken)
text
- the hyperlink's textasHTML
- true
to treat the specified text as htmltargetHistoryToken
- the history token to which it will linksetTargetHistoryToken(java.lang.String)
public Hyperlink(java.lang.String text, java.lang.String targetHistoryToken)
text
- the hyperlink's texttargetHistoryToken
- the history token to which it will linkMethod Detail |
---|
public void addClickListener(ClickListener listener)
SourcesClickEvents
addClickListener
in interface SourcesClickEvents
listener
- the listener interface to addpublic java.lang.String getHTML()
HasHTML
getHTML
in interface HasHTML
public java.lang.String getTargetHistoryToken()
setTargetHistoryToken(java.lang.String)
public java.lang.String getText()
HasText
getText
in interface HasText
public void onBrowserEvent(Event event)
EventListener
onBrowserEvent
in interface EventListener
onBrowserEvent
in class Widget
event
- the event receivedpublic void removeClickListener(ClickListener listener)
SourcesClickEvents
removeClickListener
in interface SourcesClickEvents
listener
- the listener interface to removepublic void setHTML(java.lang.String html)
HasHTML
HasText.setText(String)
whenever possible.
setHTML
in interface HasHTML
html
- the object's new HTMLpublic void setTargetHistoryToken(java.lang.String targetHistoryToken)
History.newItem(java.lang.String)
when this link is
clicked.
targetHistoryToken
- the new target history tokenpublic void setText(java.lang.String text)
HasText
setText
in interface HasText
text
- the object's new text
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |