public class HTML extends Label implements HasDirectionalHtml, HasDirectionalSafeHtml
If you only need a simple label (text, but not HTML), then the
Label
widget is more appropriate, as it
disallows the use of HTML, which can lead to potential security issues if not
used properly.
LabelBase.setDirectionEstimator(boolean)
or
passing a DirectionEstimator parameter to the constructor, and is off by
default.
UIObject.DebugIdImpl, UIObject.DebugIdImplEnabled
HasDirection.Direction
HasHorizontalAlignment.AutoHorizontalAlignmentConstant, HasHorizontalAlignment.HorizontalAlignmentConstant
DEFAULT_DIRECTION_ESTIMATOR
DEBUG_ID_PREFIX
ALIGN_CONTENT_END, ALIGN_CONTENT_START
ALIGN_CENTER, ALIGN_DEFAULT, ALIGN_JUSTIFY, ALIGN_LEFT, ALIGN_LOCALE_END, ALIGN_LOCALE_START, ALIGN_RIGHT
Modifier | Constructor and Description |
---|---|
|
HTML()
Creates an empty HTML widget.
|
protected |
HTML(Element element)
This constructor may be used by subclasses to explicitly use an existing
element.
|
|
HTML(SafeHtml html)
Initializes the widget's HTML from a given
SafeHtml object. |
|
HTML(SafeHtml html,
DirectionEstimator directionEstimator)
Creates an HTML widget with the specified HTML contents and specifies a
direction estimator.
|
|
HTML(SafeHtml html,
HasDirection.Direction dir)
Creates an HTML widget with the specified contents and with the specified
direction.
|
|
HTML(String html)
Creates an HTML widget with the specified HTML contents.
|
|
HTML(String html,
boolean wordWrap)
Creates an HTML widget with the specified contents, optionally treating it
as HTML, and optionally disabling word wrapping.
|
|
HTML(String html,
HasDirection.Direction dir)
Creates an HTML widget with the specified HTML contents and with the
specified direction.
|
Modifier and Type | Method and Description |
---|---|
String |
getHTML()
Gets this object's contents as HTML.
|
protected String |
getTextOrHtml(boolean isHtml) |
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 the label's content to the given HTML.
|
void |
setHTML(String html,
HasDirection.Direction dir)
Sets the label's content to the given HTML, applying the given direction.
|
static HTML |
wrap(Element element)
Creates an HTML widget that wraps an existing <div> or <span>
element.
|
addClickHandler, addClickListener, addDoubleClickHandler, addDragEndHandler, addDragEnterHandler, addDragHandler, addDragLeaveHandler, addDragOverHandler, addDragStartHandler, addDropHandler, addGestureChangeHandler, addGestureEndHandler, addGestureStartHandler, addMouseDownHandler, addMouseListener, addMouseMoveHandler, addMouseOutHandler, addMouseOverHandler, addMouseUpHandler, addMouseWheelHandler, addMouseWheelListener, addTouchCancelHandler, addTouchEndHandler, addTouchMoveHandler, addTouchStartHandler, asEditor, getDirection, getText, getTextDirection, removeClickListener, removeMouseListener, removeMouseWheelListener, setDirection, setText, setText
getAutoHorizontalAlignment, getDirectionEstimator, getHorizontalAlignment, getWordWrap, setAutoHorizontalAlignment, setDirectionEstimator, setDirectionEstimator, setHorizontalAlignment, setWordWrap, updateHorizontalAlignment
addAttachHandler, addBitlessDomHandler, addDomHandler, addHandler, asWidget, asWidgetOrNull, createHandlerManager, delegateEvent, doAttachChildren, doDetachChildren, fireEvent, getHandlerCount, getLayoutData, getParent, isAttached, isOrWasAttached, onAttach, onBrowserEvent, 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, onEnsureDebugId, removeStyleDependentName, removeStyleName, resolvePotentialElement, setElement, setElement, setHeight, setPixelSize, setSize, setStyleDependentName, setStyleName, setStyleName, setStyleName, setStyleName, setStylePrimaryName, setStylePrimaryName, setTitle, setVisible, setVisible, setWidth, sinkBitlessEvent, toString
getTextDirection, setText
fireEvent
public HTML()
public HTML(SafeHtml html)
SafeHtml
object.html
- the new widget's HTML contentspublic HTML(SafeHtml html, HasDirection.Direction dir)
html
- the new widget's SafeHtml contentsdir
- the content's direction. Note: Direction.DEFAULT
means
direction should be inherited from the widget's parent element.public HTML(SafeHtml html, DirectionEstimator directionEstimator)
html
- the new widget's SafeHtml contentsdirectionEstimator
- A DirectionEstimator object used for automatic
direction adjustment. For convenience,
Label.DEFAULT_DIRECTION_ESTIMATOR
can be used.public HTML(String html)
html
- the new widget's HTML contentspublic HTML(String html, HasDirection.Direction dir)
html
- the new widget's HTML contentsdir
- the content's direction. Note: Direction.DEFAULT
means
direction should be inherited from the widget's parent element.public HTML(String html, boolean wordWrap)
html
- the widget's contentswordWrap
- false
to disable word wrappingprotected HTML(Element element)
element
- the element to be usedpublic static HTML wrap(Element element)
RootPanel.detachNow(Widget)
.element
- the element to be wrappedpublic String getHTML()
HasHTML
public void setHTML(String html)
Label.setText(String)
for details on potential effects on direction
and alignment.public void setHTML(String html, HasDirection.Direction dir)
setText(String, Direction)
for details on potential effects on alignment.setHTML
in interface HasDirectionalHtml
html
- the new widget's HTML contentdir
- the content's direction. Note: Direction.DEFAULT
means
direction should be inherited from the widget's parent element.public void setHTML(SafeHtml html)
setHTML
in interface HasSafeHtml
html
- the html to set.HasSafeHtml.setHTML(SafeHtml)
public void setHTML(SafeHtml html, HasDirection.Direction dir)
HasDirectionalSafeHtml
setHTML
in interface HasDirectionalSafeHtml
html
- the object's new htmldir
- the html's directionprotected String getTextOrHtml(boolean isHtml)
Copyright © 2018. All rights reserved.