class sap.m.FormattedText

Control sample: sap.m.FormattedText
Visiblity: public
UX Guidelines:
Implements:
Available since: N/A
Module: sap/m/FormattedText
Application Component: CA-UI5-CTR

The FormattedText control allows the usage of a limited set of tags for inline display of formatted text in HTML format.


Constructor

Constructor for a new FormattedText.

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.m.FormattedText(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


Properties

Name Type Default Value Description
convertLinksToAnchorTags sap.m.LinkConversion None

Determines whether strings that appear to be links will be converted to HTML anchor tags, and what are the criteria for recognizing them.

Since: 1.45.5.

Visibility: public
convertedLinksDefaultTarget string _blank

Determines the target attribute of the generated HTML anchor tags.

Note: Applicable only if ConvertLinksToAnchorTags property is used with a value other than sap.m.LinkConversion.None. Options are the standard values for the target attribute of the HTML anchor tag: _self, _top, _blank, _parent, _search.

Since: 1.45.5.

Visibility: public
height sap.ui.core.CSSSize

Optional height of the control in CSS units.

Visibility: public
htmlText string empty string

Text in HTML format. The following tags are supported:

  • a
  • abbr
  • bdi
  • blockquote
  • br
  • cite
  • code
  • em
  • h1
  • h2
  • h3
  • h4
  • h5
  • h6
  • p
  • pre
  • strong
  • span
  • u
  • dl
  • dt
  • dd
  • ul
  • ol
  • li

class, style, dir, and target attributes are allowed. If target is not set, links open in a new window by default.

Only safe href attributes can be used. See URLListValidator.

Note: Keep in mind that not supported HTML tags and the content nested inside them are both not rendered by the control.

Visibility: public
textAlign sap.ui.core.TextAlign Begin

Determines the text alignment in the text elements in the FormattedText.

Note: This functionality if set to the root element. To set explicit alignment to an element use the style attribute.

Since: 1.86.0.

Visibility: public
textDirection sap.ui.core.TextDirection Inherit

Defines the directionality of the text in the FormattedText, e.g. right-to-left(RTL) or left-to-right (LTR).

Note: This functionality if set to the root element. Use the bdi element and the dir attribute to set explicit direction to an element.

Since: 1.86.0.

Visibility: public
width sap.ui.core.CSSSize

Optional width of the control in CSS units.

Visibility: public

Aggregations

Default Aggregation:

Name Cardinality Type Description
controls 0..n sap.m.Link

List of sap.m.Link controls that will be used to replace the placeholders in the text. Placeholders are replaced according to their indexes. The placeholder with index %%0 will be replaced by the first link in the aggregation, etc.


Methods Overview

Method Description
_setUseLimitedRenderingRules

Sets should a limited list of rendering rules be used instead of the default one. This limited list will evaluate only a small subset of the default HTML elements and attributes.

addControl

Adds some control to the aggregation controls.

destroyControls

Destroys all the controls in the aggregation controls.

sap.m.FormattedText.extend

Creates a new subclass of class sap.m.FormattedText 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.

getControls

Gets content of aggregation controls.

List of sap.m.Link controls that will be used to replace the placeholders in the text. Placeholders are replaced according to their indexes. The placeholder with index %%0 will be replaced by the first link in the aggregation, etc.

getConvertedLinksDefaultTarget

Gets current value of property convertedLinksDefaultTarget.

Determines the target attribute of the generated HTML anchor tags.

Note: Applicable only if ConvertLinksToAnchorTags property is used with a value other than sap.m.LinkConversion.None. Options are the standard values for the target attribute of the HTML anchor tag: _self, _top, _blank, _parent, _search.

Default value is "_blank".

getConvertLinksToAnchorTags

Gets current value of property convertLinksToAnchorTags.

Determines whether strings that appear to be links will be converted to HTML anchor tags, and what are the criteria for recognizing them.

Default value is None.

getHeight

Gets current value of property height.

Optional height of the control in CSS units.

getHtmlText

Gets current value of property htmlText.

Text in HTML format. The following tags are supported:

  • a
  • abbr
  • bdi
  • blockquote
  • br
  • cite
  • code
  • em
  • h1
  • h2
  • h3
  • h4
  • h5
  • h6
  • p
  • pre
  • strong
  • span
  • u
  • dl
  • dt
  • dd
  • ul
  • ol
  • li

class, style, dir, and target attributes are allowed. If target is not set, links open in a new window by default.

Only safe href attributes can be used. See URLListValidator.

Note: Keep in mind that not supported HTML tags and the content nested inside them are both not rendered by the control.

Default value is empty string.

sap.m.FormattedText.getMetadata

Returns a metadata object for class sap.m.FormattedText.

getTextAlign

Gets current value of property textAlign.

Determines the text alignment in the text elements in the FormattedText.

Note: This functionality if set to the root element. To set explicit alignment to an element use the style attribute.

Default value is Begin.

getTextDirection

Gets current value of property textDirection.

Defines the directionality of the text in the FormattedText, e.g. right-to-left(RTL) or left-to-right (LTR).

Note: This functionality if set to the root element. Use the bdi element and the dir attribute to set explicit direction to an element.

Default value is Inherit.

getWidth

Gets current value of property width.

Optional width of the control in CSS units.

indexOfControl

Checks for the provided sap.m.Link in the aggregation controls. and returns its index if found or -1 otherwise.

insertControl

Inserts a control into the aggregation controls.

removeAllControls

Removes all the controls from the aggregation controls.

Additionally, it unregisters them from the hosting UIArea.

removeControl

Removes a control from the aggregation controls.

setConvertedLinksDefaultTarget

Sets a new value for property convertedLinksDefaultTarget.

Determines the target attribute of the generated HTML anchor tags.

Note: Applicable only if ConvertLinksToAnchorTags property is used with a value other than sap.m.LinkConversion.None. Options are the standard values for the target attribute of the HTML anchor tag: _self, _top, _blank, _parent, _search.

When called with a value of null or undefined, the default value of the property will be restored.

Default value is "_blank".

setConvertLinksToAnchorTags

Sets a new value for property convertLinksToAnchorTags.

Determines whether strings that appear to be links will be converted to HTML anchor tags, and what are the criteria for recognizing them.

When called with a value of null or undefined, the default value of the property will be restored.

Default value is None.

setHeight

Sets a new value for property height.

Optional height of the control in CSS units.

When called with a value of null or undefined, the default value of the property will be restored.

setHtmlText

Defines the HTML text to be displayed.

setTextAlign

Sets a new value for property textAlign.

Determines the text alignment in the text elements in the FormattedText.

Note: This functionality if set to the root element. To set explicit alignment to an element use the style attribute.

When called with a value of null or undefined, the default value of the property will be restored.

Default value is Begin.

setTextDirection

Sets a new value for property textDirection.

Defines the directionality of the text in the FormattedText, e.g. right-to-left(RTL) or left-to-right (LTR).

Note: This functionality if set to the root element. Use the bdi element and the dir attribute to set explicit direction to an element.

When called with a value of null or undefined, the default value of the property will be restored.

Default value is Inherit.

setWidth

Sets a new value for property width.

Optional width of the control in CSS units.

When called with a value of null or undefined, the default value of the property will be restored.

_setUseLimitedRenderingRules

Sets should a limited list of rendering rules be used instead of the default one. This limited list will evaluate only a small subset of the default HTML elements and attributes.

Param Type DefaultValue Description
bLimit boolean

Should the control use the limited list

addControl

Adds some control to the aggregation controls.

Param Type DefaultValue Description
oControl sap.m.Link

The control to add; if empty, nothing is inserted

destroyControls

Destroys all the controls in the aggregation controls.

sap.m.FormattedText.extend

Creates a new subclass of class sap.m.FormattedText 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

getControls

Gets content of aggregation controls.

List of sap.m.Link controls that will be used to replace the placeholders in the text. Placeholders are replaced according to their indexes. The placeholder with index %%0 will be replaced by the first link in the aggregation, etc.

getConvertedLinksDefaultTarget

Gets current value of property convertedLinksDefaultTarget.

Determines the target attribute of the generated HTML anchor tags.

Note: Applicable only if ConvertLinksToAnchorTags property is used with a value other than sap.m.LinkConversion.None. Options are the standard values for the target attribute of the HTML anchor tag: _self, _top, _blank, _parent, _search.

Default value is "_blank".

getConvertLinksToAnchorTags

Gets current value of property convertLinksToAnchorTags.

Determines whether strings that appear to be links will be converted to HTML anchor tags, and what are the criteria for recognizing them.

Default value is None.

getHeight

Gets current value of property height.

Optional height of the control in CSS units.

getHtmlText

Gets current value of property htmlText.

Text in HTML format. The following tags are supported:

class, style, dir, and target attributes are allowed. If target is not set, links open in a new window by default.

Only safe href attributes can be used. See URLListValidator.

Note: Keep in mind that not supported HTML tags and the content nested inside them are both not rendered by the control.

Default value is empty string.

sap.m.FormattedText.getMetadata

Returns a metadata object for class sap.m.FormattedText.

getTextAlign

Gets current value of property textAlign.

Determines the text alignment in the text elements in the FormattedText.

Note: This functionality if set to the root element. To set explicit alignment to an element use the style attribute.

Default value is Begin.

getTextDirection

Gets current value of property textDirection.

Defines the directionality of the text in the FormattedText, e.g. right-to-left(RTL) or left-to-right (LTR).

Note: This functionality if set to the root element. Use the bdi element and the dir attribute to set explicit direction to an element.

Default value is Inherit.

getWidth

Gets current value of property width.

Optional width of the control in CSS units.

indexOfControl

Checks for the provided sap.m.Link in the aggregation controls. and returns its index if found or -1 otherwise.

Param Type DefaultValue Description
oControl sap.m.Link

The control whose index is looked for

insertControl

Inserts a control into the aggregation controls.

Param Type DefaultValue Description
oControl sap.m.Link

The control to insert; if empty, nothing is inserted

iIndex int

The 0-based index the control should be inserted at; for a negative value of iIndex, the control is inserted at position 0; for a value greater than the current size of the aggregation, the control is inserted at the last position

removeAllControls

Removes all the controls from the aggregation controls.

Additionally, it unregisters them from the hosting UIArea.

removeControl

Removes a control from the aggregation controls.

Param Type DefaultValue Description
vControl int string sap.m.Link

The control to remove or its index or id

setConvertedLinksDefaultTarget

Sets a new value for property convertedLinksDefaultTarget.

Determines the target attribute of the generated HTML anchor tags.

Note: Applicable only if ConvertLinksToAnchorTags property is used with a value other than sap.m.LinkConversion.None. Options are the standard values for the target attribute of the HTML anchor tag: _self, _top, _blank, _parent, _search.

When called with a value of null or undefined, the default value of the property will be restored.

Default value is "_blank".

Param Type DefaultValue Description
sConvertedLinksDefaultTarget string "_blank"

New value for property convertedLinksDefaultTarget

setConvertLinksToAnchorTags

Sets a new value for property convertLinksToAnchorTags.

Determines whether strings that appear to be links will be converted to HTML anchor tags, and what are the criteria for recognizing them.

When called with a value of null or undefined, the default value of the property will be restored.

Default value is None.

Param Type DefaultValue Description
sConvertLinksToAnchorTags sap.m.LinkConversion None

New value for property convertLinksToAnchorTags

setHeight

Sets a new value for property height.

Optional height of the control in CSS units.

When called with a value of null or undefined, the default value of the property will be restored.

Param Type DefaultValue Description
sHeight sap.ui.core.CSSSize

New value for property height

setHtmlText

Defines the HTML text to be displayed.

Param Type DefaultValue Description
sText string

HTML text as a string

setTextAlign

Sets a new value for property textAlign.

Determines the text alignment in the text elements in the FormattedText.

Note: This functionality if set to the root element. To set explicit alignment to an element use the style attribute.

When called with a value of null or undefined, the default value of the property will be restored.

Default value is Begin.

Param Type DefaultValue Description
sTextAlign sap.ui.core.TextAlign Begin

New value for property textAlign

setTextDirection

Sets a new value for property textDirection.

Defines the directionality of the text in the FormattedText, e.g. right-to-left(RTL) or left-to-right (LTR).

Note: This functionality if set to the root element. Use the bdi element and the dir attribute to set explicit direction to an element.

When called with a value of null or undefined, the default value of the property will be restored.

Default value is Inherit.

Param Type DefaultValue Description
sTextDirection sap.ui.core.TextDirection Inherit

New value for property textDirection

setWidth

Sets a new value for property width.

Optional width of the control in CSS units.

When called with a value of null or undefined, the default value of the property will be restored.

Param Type DefaultValue Description
sWidth sap.ui.core.CSSSize

New value for property width