Embeds standard HTML in an SAPUI5 control tree.
Security Hint: By default, the HTML content (property 'content') is not sanitized and therefore open to XSS attacks. Applications that want to show user defined input in an HTML control, should either sanitize the content on their own or activate automatic sanitizing through the sanitizeContent property.
Although this control inherits the tooltip
aggregation/property and the hasStyleClass
, addStyleClass
, removeStyleClass
and toggleStyleClass
methods from its base class, it doesn't support them. Instead, the defined HTML content can contain a tooltip (title attribute) or custom CSS classes.
For further hints about usage restrictions for this control, see also the documentation of the content
property.
Constructor for a new HTML.
Accepts an object literal mSettings
that defines initial property values, aggregated and associated objects as well as event handlers. See sap.ui.base.ManagedObject#constructor for a general description of the syntax of the settings object.
new sap.ui.core.HTML(sId?, mSettings?)
Param | Type | Default Value | Description |
---|---|---|---|
sId? | string | id for the new control, generated automatically if no id is given |
|
mSettings? | object | initial settings for the new control |
Name | Type | Default Value | Description |
---|---|---|---|
content | string | HTML content to be displayed, defined as a string. The content is converted to DOM nodes with a call to Some of these restrictions (there might be others!) are:
Please consider to consult the jQuery documentation as well. The HTML control currently doesn't prevent the usage of multiple root nodes in its DOM content (e.g. When changing the content dynamically, ensure that the ID of the root node remains the same as the HTML control's ID. Otherwise it cannot be guaranteed that certain lifecycle events take place. Visibility: public |
|
preferDOM | boolean | true | Whether existing DOM content is preferred over the given content string. There are two scenarios where this flag is relevant (when set to true):
As preserving the existing DOM is the most common use case of the HTML control, the default value is true. Visibility: public |
sanitizeContent | boolean | false | Whether to run the HTML sanitizer once the content (HTML markup) is applied or not. To configure the set of allowed URLs, you can use the URLListValidator API. Visibility: public |
visible | boolean | true | Specifies whether the control is visible. Invisible controls are not rendered. Visibility: public |
Name | Type | Default Value | Description |
---|---|---|---|
blocked | boolean | false | Whether the control is currently in blocked state. Visibility: public |
busy | boolean | false | Whether the control is currently in busy state. Visibility: public |
busyIndicatorDelay | int | 1000 | The delay in milliseconds, after which the busy indicator will show up for this control. Visibility: public |
busyIndicatorSize | sap.ui.core.BusyIndicatorSize | Medium | The size of the BusyIndicator. For controls with a width smaller 3rem a |
fieldGroupIds | string[] | The IDs of a logical field group that this control belongs to. All fields in a logical field group should share the same For backward compatibility with older releases, field group IDs are syntactically not limited, but it is suggested to use only valid sap.ui.core.IDs. See #attachValidateFieldGroup or consult the Field Group documentation. |
|
visible | boolean | true | Whether the control should be visible on the screen. If set to false, a placeholder will be rendered to mark the location of the invisible control in the DOM of the current page. The placeholder will be hidden and have zero dimensions ( Also see InvisibleRenderer. Visibility: public |
Name | Cardinality | Type | Description |
---|---|---|---|
customData | 0..n | sap.ui.core.CustomData |
Custom Data, a data structure like a map containing arbitrary key value pairs. |
dependents | 0..n | sap.ui.core.Element |
Dependents are not rendered, but their databinding context and lifecycle are bound to the aggregating Element. |
dragDropConfig | 0..n | sap.ui.core.dnd.DragDropBase |
Defines the drag-and-drop configuration. Note: This configuration might be ignored due to control metadata restrictions. |
layoutData | 0..1 | sap.ui.core.LayoutData |
Defines the layout constraints for this control when it is used inside a Layout. LayoutData classes are typed classes and must match the embedding Layout. See VariantLayoutData for aggregating multiple alternative LayoutData instances to a single Element. |
tooltip | 0..1 | sap.ui.core.TooltipBase |
The tooltip that should be shown for this Element. In the most simple case, a tooltip is a string that will be rendered by the control and displayed by the browser when the mouse pointer hovers over the control's DOM. In this variant, Controls need to explicitly support this kind of tooltip as they have to render it, but most controls do. Exceptions will be documented for the corresponding controls (e.g. Alternatively, UI5 currently does not provide a recommended implementation of See the section Using Tooltips
|
Event | Description |
---|---|
afterRendering |
Fired after the HTML control has been rendered. Allows to manipulate the resulting DOM. When the control doesn't have string content and no preserved DOM existed for this control, then this event will fire, but there won't be a DOM node for this control. |
Fired after the HTML control has been rendered. Allows to manipulate the resulting DOM.
When the control doesn't have string content and no preserved DOM existed for this control, then this event will fire, but there won't be a DOM node for this control.
Param | Type | Description |
---|---|---|
oControlEvent | sap.ui.base.Event | |
getSource | sap.ui.base.EventProvider | |
getParameters | object | |
isPreservedDOM | boolean |
Whether the current DOM of the control has been preserved (true) or not (e.g. rendered from content property or it is an empty HTML control). |
Method | Description |
---|---|
attachAfterRendering |
Attaches event handler When called, the context of the event handler (its Fired after the HTML control has been rendered. Allows to manipulate the resulting DOM. When the control doesn't have string content and no preserved DOM existed for this control, then this event will fire, but there won't be a DOM node for this control. |
detachAfterRendering |
Detaches event handler The passed function and listener object must match the ones used for event registration. |
sap.ui.core.HTML.extend |
Creates a new subclass of class sap.ui.core.HTML with name
|
fireAfterRendering |
Fires event afterRendering to attached listeners. |
getContent |
Gets current value of property content. HTML content to be displayed, defined as a string. The content is converted to DOM nodes with a call to Some of these restrictions (there might be others!) are:
Please consider to consult the jQuery documentation as well. The HTML control currently doesn't prevent the usage of multiple root nodes in its DOM content (e.g. When changing the content dynamically, ensure that the ID of the root node remains the same as the HTML control's ID. Otherwise it cannot be guaranteed that certain lifecycle events take place. |
getDomRef | |
sap.ui.core.HTML.getMetadata |
Returns a metadata object for class sap.ui.core.HTML. |
getPreferDOM |
Gets current value of property preferDOM. Whether existing DOM content is preferred over the given content string. There are two scenarios where this flag is relevant (when set to true):
As preserving the existing DOM is the most common use case of the HTML control, the default value is true. Default value is |
getSanitizeContent |
Gets current value of property sanitizeContent. Whether to run the HTML sanitizer once the content (HTML markup) is applied or not. To configure the set of allowed URLs, you can use the URLListValidator API. Default value is |
getVisible |
Gets current value of property visible. Specifies whether the control is visible. Invisible controls are not rendered. Default value is |
setContent |
Sets a new value for property content. HTML content to be displayed, defined as a string. The content is converted to DOM nodes with a call to Some of these restrictions (there might be others!) are:
Please consider to consult the jQuery documentation as well. The HTML control currently doesn't prevent the usage of multiple root nodes in its DOM content (e.g. When changing the content dynamically, ensure that the ID of the root node remains the same as the HTML control's ID. Otherwise it cannot be guaranteed that certain lifecycle events take place. When called with a value of |
setDOMContent |
Sets some new DOM content for this HTML control. The content will replace the existing content after the next rendering. Properties are not modified, but preferDOM should be set to true. |
setPreferDOM |
Sets a new value for property preferDOM. Whether existing DOM content is preferred over the given content string. There are two scenarios where this flag is relevant (when set to true):
As preserving the existing DOM is the most common use case of the HTML control, the default value is true. When called with a value of Default value is |
setSanitizeContent |
Sets a new value for property sanitizeContent. Whether to run the HTML sanitizer once the content (HTML markup) is applied or not. To configure the set of allowed URLs, you can use the URLListValidator API. When called with a value of Default value is |
setVisible |
Sets a new value for property visible. Specifies whether the control is visible. Invisible controls are not rendered. When called with a value of Default value is |
Attaches event handler fnFunction
to the afterRendering event of this sap.ui.core.HTML
.
When called, the context of the event handler (its this
) will be bound to oListener
if specified, otherwise it will be bound to this sap.ui.core.HTML
itself.
Fired after the HTML control has been rendered. Allows to manipulate the resulting DOM.
When the control doesn't have string content and no preserved DOM existed for this control, then this event will fire, but there won't be a DOM node for this control.
Param | Type | DefaultValue | Description |
---|---|---|---|
oData | object |
An application-specific payload object that will be passed to the event handler along with the event object when firing the event |
|
fnFunction | function(sap.ui.base.Event) : void |
The function to be called when the event occurs |
|
oListener | object |
Context object to call the event handler with. Defaults to this |
Detaches event handler fnFunction
from the afterRendering event of this sap.ui.core.HTML
.
The passed function and listener object must match the ones used for event registration.
Param | Type | DefaultValue | Description |
---|---|---|---|
fnFunction | function(sap.ui.base.Event) : void |
The function to be called, when the event occurs |
|
oListener | object |
Context object on which the given function had to be called |
Creates a new subclass of class sap.ui.core.HTML with name sClassName
and enriches it with the information contained in oClassInfo
.
oClassInfo
might contain the same kind of information as described in sap.ui.core.Control.extend.
Param | Type | DefaultValue | Description |
---|---|---|---|
sClassName | string |
Name of the class being created |
|
oClassInfo | object |
Object literal with information about the class |
|
FNMetaImpl | function |
Constructor function for the metadata object; if not given, it defaults to the metadata implementation used by this class |
Fires event afterRendering to attached listeners.
Param | Type | DefaultValue | Description |
---|---|---|---|
mParameters | object |
Parameters to pass along with the event |
|
isPreservedDOM | boolean |
Whether the current DOM of the control has been preserved (true) or not (e.g. rendered from content property or it is an empty HTML control). |
Gets current value of property content.
HTML content to be displayed, defined as a string.
The content is converted to DOM nodes with a call to new jQuery(content)
, so any restrictions for the jQuery constructor apply to the content of the HTML control as well.
Some of these restrictions (there might be others!) are:
Please consider to consult the jQuery documentation as well.
The HTML control currently doesn't prevent the usage of multiple root nodes in its DOM content (e.g. setContent("<div></div><div></div>")
), but this is not a guaranteed feature. The accepted content might be restricted to single root nodes in future versions. To notify applications about this fact, a warning is written in the log when multiple root nodes are used.
When changing the content dynamically, ensure that the ID of the root node remains the same as the HTML control's ID. Otherwise it cannot be guaranteed that certain lifecycle events take place.
Param | Type | DefaultValue | Description |
---|---|---|---|
sSuffix | string | '' |
Suffix of the Element to be retrieved or empty |
Gets current value of property preferDOM.
Whether existing DOM content is preferred over the given content string.
There are two scenarios where this flag is relevant (when set to true):
As preserving the existing DOM is the most common use case of the HTML control, the default value is true.
Default value is true
.
Gets current value of property sanitizeContent.
Whether to run the HTML sanitizer once the content (HTML markup) is applied or not.
To configure the set of allowed URLs, you can use the URLListValidator API.
Default value is false
.
Gets current value of property visible.
Specifies whether the control is visible. Invisible controls are not rendered.
Default value is true
.
Sets a new value for property content.
HTML content to be displayed, defined as a string.
The content is converted to DOM nodes with a call to new jQuery(content)
, so any restrictions for the jQuery constructor apply to the content of the HTML control as well.
Some of these restrictions (there might be others!) are:
Please consider to consult the jQuery documentation as well.
The HTML control currently doesn't prevent the usage of multiple root nodes in its DOM content (e.g. setContent("<div></div><div></div>")
), but this is not a guaranteed feature. The accepted content might be restricted to single root nodes in future versions. To notify applications about this fact, a warning is written in the log when multiple root nodes are used.
When changing the content dynamically, ensure that the ID of the root node remains the same as the HTML control's ID. Otherwise it cannot be guaranteed that certain lifecycle events take place.
When called with a value of null
or undefined
, the default value of the property will be restored.
Param | Type | DefaultValue | Description |
---|---|---|---|
sContent | string |
New value for property |
Sets some new DOM content for this HTML control. The content will replace the existing content after the next rendering. Properties are not modified, but preferDOM should be set to true.
Param | Type | DefaultValue | Description |
---|---|---|---|
oDom | Element |
the new DOM content |
Sets a new value for property preferDOM.
Whether existing DOM content is preferred over the given content string.
There are two scenarios where this flag is relevant (when set to true):
As preserving the existing DOM is the most common use case of the HTML control, the default value is true.
When called with a value of null
or undefined
, the default value of the property will be restored.
Default value is true
.
Param | Type | DefaultValue | Description |
---|---|---|---|
bPreferDOM | boolean | true |
New value for property |
Sets a new value for property sanitizeContent.
Whether to run the HTML sanitizer once the content (HTML markup) is applied or not.
To configure the set of allowed URLs, you can use the URLListValidator API.
When called with a value of null
or undefined
, the default value of the property will be restored.
Default value is false
.
Param | Type | DefaultValue | Description |
---|---|---|---|
bSanitizeContent | boolean | false |
New value for property |
Sets a new value for property visible.
Specifies whether the control is visible. Invisible controls are not rendered.
When called with a value of null
or undefined
, the default value of the property will be restored.
Default value is true
.
Param | Type | DefaultValue | Description |
---|---|---|---|
bVisible | boolean | true |
New value for property |