public class Html extends Component
Note that it is the developer's responsibility to sanitize and remove any dangerous parts of the HTML before sending it to the user through this component. Passing raw input data to the user will possibly lead to cross-site scripting attacks.
This component does not expand the HTML fragment into a server side DOM tree
so you cannot traverse or modify the HTML on the server. The root element can
be accessed through Component.getElement()
and the inner HTML through
getInnerHtml()
.
The HTML fragment cannot be changed after creation. You should create a new instance to encapsulate another fragment.
Constructor and Description |
---|
Html(InputStream stream)
Creates an instance based on the HTML fragment read from the stream.
|
Html(String outerHtml)
Creates an instance based on the given HTML fragment.
|
Modifier and Type | Method and Description |
---|---|
String |
getInnerHtml()
Gets the inner HTML, i.e.
|
addListener, fireEvent, from, get, getChildren, getElement, getEventBus, getId, getLocale, getParent, getTranslation, getTranslation, getUI, hasListener, isTemplateMapped, isVisible, onAttach, onDetach, onEnabledStateChanged, set, setElement, setId, setVisible
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
addAttachListener
addDetachListener
public Html(InputStream stream)
A best effort is done to parse broken HTML but no guarantees are given for how invalid HTML is handled.
Any heading or trailing whitespace is removed while parsing but any whitespace inside the root tag is preserved.
stream
- the input stream which provides the HTML in UTF-8UncheckedIOException
- if reading the stream failspublic Html(String outerHtml)
A best effort is done to parse broken HTML but no guarantees are given for how invalid HTML is handled.
Any heading or trailing whitespace is removed while parsing but any whitespace inside the root tag is preserved.
outerHtml
- the HTML to wrappublic String getInnerHtml()
null
Copyright © 2018. All rights reserved.