class sap.m.MessageStrip

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

MessageStrip is a control that enables the embedding of application-related messages in the application.

Overview

The message strip displays 4 types of messages, each with a corresponding semantic color and icon: Information, Success, Warning and Error.

Each message can have a close button, so that it can be removed from the UI if needed.

You can use a limited set of formatting tags for the message text by setting enableFormattedText. The allowed tags are: With version 1.50

With version 1.85

Dynamically generated Message Strip

To meet the accessibility requirements when using dynamically generated Message Strip you must implement it alongside sap.ui.core.InvisibleMessage. This will allow screen readers to announce it in real time. We suggest such dynamically generated message strips to be announced as Information Bar, as shown in our “Dynamic Message Strip Generator sample.”

Usage

When to use

When not to use

This control can be a drag source.

Constructor

Constructor for a new MessageStrip.

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.MessageStrip(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
customIcon sap.ui.core.URI empty string

Determines a custom icon which is displayed. If none is set, the default icon for this message type is used.

Visibility: public
enableFormattedText boolean false

Determines the limited collection of HTML elements passed to the text property should be evaluated.

Note: If this property is set to true the string passed to text property can evaluate the following list of limited HTML elements. All other HTML elements and their nested content will not be rendered by the control:

  • a
  • br
  • em
  • strong
  • u


Since: 1.50.

Visibility: public
showCloseButton boolean false

Determines if the message has a close button in the upper right corner.

Visibility: public
showIcon boolean false

Determines if an icon is displayed for the message.

Visibility: public
text string empty string

Determines the text of the message.

Visibility: public
type sap.ui.core.MessageType Information

Determines the type of messages that are displayed in the MessageStrip. Possible values are: Information (default), Success, Warning, Error. If None is passed, the value is set to Information and a warning is displayed in the console.

Visibility: public

Aggregations

Default Aggregation: link

Name Cardinality Type Description
_closeButton 0..1 sap.m.Button

Hidden aggregation which is used to create the close button with sap.m.Button control.

_formattedText 0..1 sap.m.FormattedText

Hidden aggregation which is used to transform the string message into sap.m.Text control.

_text 0..1 sap.m.Text

Hidden aggregation which is used to transform the string message into sap.m.Text control.


Events Overview

Event Description
close

This event will be fired after the container is closed.

close

This event will be fired after the container is closed.

Param Type Description
oControlEvent sap.ui.base.Event
getSource sap.ui.base.EventProvider
getParameters object

Methods Overview

Method Description
attachClose

Attaches event handler fnFunction to the close event of this sap.m.MessageStrip.

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.m.MessageStrip itself.

This event will be fired after the container is closed.

close

Closes the MessageStrip. This method sets the visible property of the MessageStrip to false. The MessageStrip can be shown again by setting the visible property to true.

destroyLink

Destroys the link in the aggregation link.

detachClose

Detaches event handler fnFunction from the close event of this sap.m.MessageStrip.

The passed function and listener object must match the ones used for event registration.

sap.m.MessageStrip.extend

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

fireClose

Fires event close to attached listeners.

getCustomIcon

Gets current value of property customIcon.

Determines a custom icon which is displayed. If none is set, the default icon for this message type is used.

Default value is empty string.

getEnableFormattedText

Gets current value of property enableFormattedText.

Determines the limited collection of HTML elements passed to the text property should be evaluated.

Note: If this property is set to true the string passed to text property can evaluate the following list of limited HTML elements. All other HTML elements and their nested content will not be rendered by the control:

  • a
  • br
  • em
  • strong
  • u

Default value is false.

getLink

Gets content of aggregation link.

Adds an sap.m.Link control which will be displayed at the end of the message.

sap.m.MessageStrip.getMetadata

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

getShowCloseButton

Gets current value of property showCloseButton.

Determines if the message has a close button in the upper right corner.

Default value is false.

getShowIcon

Gets current value of property showIcon.

Determines if an icon is displayed for the message.

Default value is false.

getText

Gets current value of property text.

Determines the text of the message.

Default value is empty string.

getType

Gets current value of property type.

Determines the type of messages that are displayed in the MessageStrip. Possible values are: Information (default), Success, Warning, Error. If None is passed, the value is set to Information and a warning is displayed in the console.

Default value is Information.

setCustomIcon

Sets a new value for property customIcon.

Determines a custom icon which is displayed. If none is set, the default icon for this message type is used.

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

Default value is empty string.

setEnableFormattedText

Sets a new value for property enableFormattedText.

Determines the limited collection of HTML elements passed to the text property should be evaluated.

Note: If this property is set to true the string passed to text property can evaluate the following list of limited HTML elements. All other HTML elements and their nested content will not be rendered by the control:

  • a
  • br
  • em
  • strong
  • u

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

Default value is false.

setLink

Sets the aggregated link.

setShowCloseButton

Sets a new value for property showCloseButton.

Determines if the message has a close button in the upper right corner.

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

Default value is false.

setShowIcon

Sets a new value for property showIcon.

Determines if an icon is displayed for the message.

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

Default value is false.

setText

Setter for property text. Default value is empty/undefined

setType

Sets a new value for property type.

Determines the type of messages that are displayed in the MessageStrip. Possible values are: Information (default), Success, Warning, Error. If None is passed, the value is set to Information and a warning is displayed in the console.

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

Default value is Information.

attachClose

Attaches event handler fnFunction to the close event of this sap.m.MessageStrip.

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.m.MessageStrip itself.

This event will be fired after the container is closed.

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 sap.m.MessageStrip itself

close

Closes the MessageStrip. This method sets the visible property of the MessageStrip to false. The MessageStrip can be shown again by setting the visible property to true.

detachClose

Detaches event handler fnFunction from the close event of this sap.m.MessageStrip.

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

sap.m.MessageStrip.extend

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

fireClose

Fires event close to attached listeners.

Param Type DefaultValue Description
mParameters object

Parameters to pass along with the event

getCustomIcon

Gets current value of property customIcon.

Determines a custom icon which is displayed. If none is set, the default icon for this message type is used.

Default value is empty string.

getEnableFormattedText

Gets current value of property enableFormattedText.

Determines the limited collection of HTML elements passed to the text property should be evaluated.

Note: If this property is set to true the string passed to text property can evaluate the following list of limited HTML elements. All other HTML elements and their nested content will not be rendered by the control:

Default value is false.

sap.m.MessageStrip.getMetadata

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

getShowCloseButton

Gets current value of property showCloseButton.

Determines if the message has a close button in the upper right corner.

Default value is false.

getShowIcon

Gets current value of property showIcon.

Determines if an icon is displayed for the message.

Default value is false.

getText

Gets current value of property text.

Determines the text of the message.

Default value is empty string.

getType

Gets current value of property type.

Determines the type of messages that are displayed in the MessageStrip. Possible values are: Information (default), Success, Warning, Error. If None is passed, the value is set to Information and a warning is displayed in the console.

Default value is Information.

setCustomIcon

Sets a new value for property customIcon.

Determines a custom icon which is displayed. If none is set, the default icon for this message type is used.

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

Default value is empty string.

Param Type DefaultValue Description
sCustomIcon sap.ui.core.URI ""

New value for property customIcon

setEnableFormattedText

Sets a new value for property enableFormattedText.

Determines the limited collection of HTML elements passed to the text property should be evaluated.

Note: If this property is set to true the string passed to text property can evaluate the following list of limited HTML elements. All other HTML elements and their nested content will not be rendered by the control:

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
bEnableFormattedText boolean false

New value for property enableFormattedText

setShowCloseButton

Sets a new value for property showCloseButton.

Determines if the message has a close button in the upper right corner.

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
bShowCloseButton boolean false

New value for property showCloseButton

setShowIcon

Sets a new value for property showIcon.

Determines if an icon is displayed for the message.

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
bShowIcon boolean false

New value for property showIcon

setText

Setter for property text. Default value is empty/undefined

Param Type DefaultValue Description
sText string

new value for property text

setType

Sets a new value for property type.

Determines the type of messages that are displayed in the MessageStrip. Possible values are: Information (default), Success, Warning, Error. If None is passed, the value is set to Information and a warning is displayed in the console.

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

Default value is Information.

Param Type DefaultValue Description
sType sap.ui.core.MessageType Information

New value for property type