public class Hyperlink extends Widget implements HasHTML, SourcesClickEvents, HasClickHandlers, HasDirectionEstimator, HasDirectionalSafeHtml
History.newItem(java.lang.String)
, but
without reloading the page.
If you want an HTML hyperlink (<a> tag) without interacting with the
history system, use Anchor
instead.
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.
setDirectionEstimator(boolean)
or
passing a DirectionEstimator parameter to the constructor, and is off by
default.
Anchor
UIObject.DebugIdImpl, UIObject.DebugIdImplEnabled
Modifier and Type | Field and Description |
---|---|
static DirectionEstimator |
DEFAULT_DIRECTION_ESTIMATOR |
protected DirectionalTextHelper |
directionalTextHelper |
DEBUG_ID_PREFIX
Modifier | Constructor and Description |
---|---|
|
Hyperlink()
Creates an empty hyperlink.
|
protected |
Hyperlink(Element elem) |
|
Hyperlink(SafeHtml html,
DirectionEstimator directionEstimator,
String targetHistoryToken)
Creates a hyperlink with its html and target history token specified.
|
|
Hyperlink(SafeHtml html,
HasDirection.Direction dir,
String targetHistoryToken)
Creates a hyperlink with its html and target history token specified.
|
|
Hyperlink(SafeHtml html,
String targetHistoryToken)
Creates a hyperlink with its html and target history token specified.
|
|
Hyperlink(String text,
boolean asHTML,
String targetHistoryToken)
Creates a hyperlink with its text and target history token specified.
|
|
Hyperlink(String text,
DirectionEstimator directionEstimator,
String targetHistoryToken)
Creates a hyperlink with its text and target history token specified.
|
|
Hyperlink(String text,
HasDirection.Direction dir,
String targetHistoryToken)
Creates a hyperlink with its text and target history token specified.
|
|
Hyperlink(String text,
String targetHistoryToken)
Creates a hyperlink with its text and target history token specified.
|
Modifier and Type | Method and Description |
---|---|
HandlerRegistration |
addClickHandler(ClickHandler handler)
Deprecated.
Use
FocusWidget.addClickHandler(com.google.gwt.event.dom.client.ClickHandler) instead and call
History.newItem from the handler if you need to process the
click before the history token is set. |
void |
addClickListener(ClickListener listener)
Deprecated.
Use
FocusWidget.addClickHandler(com.google.gwt.event.dom.client.ClickHandler) instead and call
History.newItem from the handler if you need to process the
click before the history token is set. |
DirectionEstimator |
getDirectionEstimator()
Returns the
DirectionEstimator object. |
String |
getHTML()
Gets this object's contents as HTML.
|
String |
getTargetHistoryToken()
Gets the history token referenced by this hyperlink.
|
String |
getText()
Gets this object's text.
|
HasDirection.Direction |
getTextDirection()
Gets the direction of this object's text.
|
void |
onBrowserEvent(Event event)
Fired whenever a browser event is received.
|
protected void |
onEnsureDebugId(String baseID)
Affected Elements:
-wrapper = the div around the link.
|
void |
removeClickListener(ClickListener listener)
Deprecated.
Use the
HandlerRegistration.removeHandler()
method on the object returned by an add*Handler method instead |
void |
setDirectionEstimator(boolean enabled)
Toggles on / off direction estimation.
|
void |
setDirectionEstimator(DirectionEstimator directionEstimator)
Sets the
DirectionEstimator object. |
void |
setHTML(SafeHtml html)
Sets this object's contents via known-safe HTML.
|
void |
setHTML(SafeHtml html,
HasDirection.Direction dir)
Sets this object's html, also declaring its direction.
|
void |
setHTML(String html)
Sets this object's contents via HTML.
|
void |
setTargetHistoryToken(String targetHistoryToken)
Sets the history token referenced by this hyperlink.
|
void |
setText(String text)
Sets this object's text.
|
void |
setText(String text,
HasDirection.Direction dir)
Sets this object's text, also declaring its direction.
|
addAttachHandler, addBitlessDomHandler, addDomHandler, addHandler, asWidget, asWidgetOrNull, createHandlerManager, delegateEvent, doAttachChildren, doDetachChildren, fireEvent, getHandlerCount, getLayoutData, getParent, isAttached, isOrWasAttached, onAttach, onDetach, onLoad, onUnload, removeFromParent, setLayoutData, sinkEvents, unsinkEvents
addStyleDependentName, addStyleName, ensureDebugId, ensureDebugId, ensureDebugId, getAbsoluteLeft, getAbsoluteTop, getElement, getOffsetHeight, getOffsetWidth, getStyleElement, getStyleName, getStyleName, getStylePrimaryName, getStylePrimaryName, getTitle, isVisible, isVisible, removeStyleDependentName, removeStyleName, resolvePotentialElement, setElement, setElement, setHeight, setPixelSize, setSize, setStyleDependentName, setStyleName, setStyleName, setStyleName, setStyleName, setStylePrimaryName, setStylePrimaryName, setTitle, setVisible, setVisible, setWidth, sinkBitlessEvent, toString
fireEvent
public static final DirectionEstimator DEFAULT_DIRECTION_ESTIMATOR
protected final DirectionalTextHelper directionalTextHelper
public Hyperlink()
public Hyperlink(SafeHtml html, String targetHistoryToken)
html
- the hyperlink's safe htmltargetHistoryToken
- the history token to which it will linksetTargetHistoryToken(java.lang.String)
public Hyperlink(SafeHtml html, HasDirection.Direction dir, String targetHistoryToken)
html
- the hyperlink's safe htmldir
- the html's directiontargetHistoryToken
- the history token to which it will linksetTargetHistoryToken(java.lang.String)
public Hyperlink(SafeHtml html, DirectionEstimator directionEstimator, String targetHistoryToken)
html
- the hyperlink's safe htmldirectionEstimator
- A DirectionEstimator object used for automatic
direction adjustment. For convenience,
DEFAULT_DIRECTION_ESTIMATOR
can be used.targetHistoryToken
- the history token to which it will linksetTargetHistoryToken(java.lang.String)
public Hyperlink(String text, String targetHistoryToken)
text
- the hyperlink's texttargetHistoryToken
- the history token to which it will link, which
may not be null (use Anchor
instead if you don't need
history processing)public Hyperlink(String text, HasDirection.Direction dir, String targetHistoryToken)
text
- the hyperlink's textdir
- the text's directiontargetHistoryToken
- the history token to which it will link, which
may not be null (use Anchor
instead if you don't need
history processing)public Hyperlink(String text, DirectionEstimator directionEstimator, String targetHistoryToken)
text
- the hyperlink's textdirectionEstimator
- A DirectionEstimator object used for automatic
direction adjustment. For convenience,
DEFAULT_DIRECTION_ESTIMATOR
can be used.targetHistoryToken
- the history token to which it will link, which
may not be null (use Anchor
instead if you don't need
history processing)public Hyperlink(String text, boolean asHTML, 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)
protected Hyperlink(Element elem)
@Deprecated public HandlerRegistration addClickHandler(ClickHandler handler)
FocusWidget.addClickHandler(com.google.gwt.event.dom.client.ClickHandler)
instead and call
History.newItem from the handler if you need to process the
click before the history token is set.HasClickHandlers
ClickEvent
handler.addClickHandler
in interface HasClickHandlers
handler
- the click handlerHandlerRegistration
used to remove this handler@Deprecated public void addClickListener(ClickListener listener)
FocusWidget.addClickHandler(com.google.gwt.event.dom.client.ClickHandler)
instead and call
History.newItem from the handler if you need to process the
click before the history token is set.SourcesClickEvents
addClickListener
in interface SourcesClickEvents
listener
- the listener interface to addpublic DirectionEstimator getDirectionEstimator()
HasDirectionEstimator
DirectionEstimator
object.getDirectionEstimator
in interface HasDirectionEstimator
public String getHTML()
HasHTML
public String getTargetHistoryToken()
setTargetHistoryToken(java.lang.String)
public HasDirection.Direction getTextDirection()
HasDirectionalText
getTextDirection
in interface HasDirectionalText
public void onBrowserEvent(Event event)
EventListener
onBrowserEvent
in interface EventListener
onBrowserEvent
in class Widget
event
- the event received@Deprecated public void removeClickListener(ClickListener listener)
HandlerRegistration.removeHandler()
method on the object returned by an add*Handler method insteadSourcesClickEvents
removeClickListener
in interface SourcesClickEvents
listener
- the listener interface to removepublic void setDirectionEstimator(boolean enabled)
See note at setDirectionEstimator(DirectionEstimator)
.
setDirectionEstimator
in interface HasDirectionEstimator
enabled
- Whether to enable direction estimation. If true
,
sets the DirectionEstimator
object to a default
DirectionEstimator
.public void setDirectionEstimator(DirectionEstimator directionEstimator)
DirectionEstimator
object.
Note: DirectionEstimator should be set before the widget has any content; it's highly recommended to set it using a constructor. Reason: if the widget already has non-empty content, this will update its direction according to the new estimator's result. This may cause flicker, and thus should be avoided.
setDirectionEstimator
in interface HasDirectionEstimator
directionEstimator
- The DirectionEstimator
to be set. null
means turning off direction estimation.public void setHTML(SafeHtml html)
HasSafeHtml
The object will behave exactly the same as when a widget's
HasHTML.setHTML(String)
method is
invoked; however the SafeHtml
passed to this method observes the
contract that it can be used in an HTML context without causing unsafe
script execution. Thus, unlike
HasHTML.setHTML(String)
, using this
method cannot result in Cross-Site Scripting security vulnerabilities.
setHTML
in interface HasSafeHtml
html
- the object's new HTML, represented as a SafeHtml
objectpublic void setHTML(String html)
HasHTML
HasText.setText(String)
whenever possible.public void setHTML(SafeHtml html, HasDirection.Direction dir)
HasDirectionalSafeHtml
setHTML
in interface HasDirectionalSafeHtml
html
- the object's new htmldir
- the html's directionpublic void setTargetHistoryToken(String targetHistoryToken)
History.newItem(java.lang.String)
when this link is
clicked.targetHistoryToken
- the new history token, which may not be null (use
Anchor
instead if you don't need history processing)public void setText(String text)
HasText
public void setText(String text, HasDirection.Direction dir)
HasDirectionalText
setText
in interface HasDirectionalText
text
- the object's new textdir
- the text's directionprotected void onEnsureDebugId(String baseID)
onEnsureDebugId
in class UIObject
baseID
- the base ID used by the main elementUIObject.onEnsureDebugId(String)
Copyright © 2018. All rights reserved.