namespace sap.m.MessageBox

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

Provides easier methods to create sap.m.Dialog with type sap.m.DialogType.Message, such as standard alerts, confirmation dialogs, or arbitrary message dialogs.

Because the MessageBox is a static class, a sap.ui.require("sap/m/MessageBox"); statement must be explicitly executed prior using the class. MessageBox provides several functions:

NOTE: All options of show() are available for the other template functions as well, but it is recommended to use show() only in more specific scenarios.
NOTE: Due to the static nature of the MessageBox class, you cannot expect data binding support from its helper functions. If this is required you can use the sap.m.Dialog instead.
NOTE: When using the MessageBox.Error method, there is no emphasized action by design.

Example:

	sap.ui.define(["sap/m/MessageBox"], function (MessageBox) {
		MessageBox.show(
			"This message should appear in the message box.", {
				icon: MessageBox.Icon.INFORMATION,
				title: "My message box title",
				actions: [MessageBox.Action.YES, MessageBox.Action.NO],
				emphasizedAction: MessageBox.Action.YES,
				onClose: function (oAction) { / * do something * / }
			}
		);
	});

When using the sap.m.MessageBox in SAP Quartz themes, the breakpoints and layout paddings could be determined by the MessageBox' width. To enable this concept and add responsive paddings to an element of the MessageBox control, you have to add the following classes depending on your use case: sapUiResponsivePadding--header, sapUiResponsivePadding--content, sapUiResponsivePadding--footer.



References:


Nodes Overview

Node Description
sap.m.MessageBox.Action

Enumeration of supported actions in a MessageBox.

sap.m.MessageBox.Icon

Enumeration of the pre-defined icons that can be used in a MessageBox.


Methods Overview

Method Description
sap.m.MessageBox.alert

Displays an alert dialog with the given message and an OK button (no icons).

sap.m.MessageBox.alert("This message should appear in the alert", {
    title: "Alert",                                      // default
    onClose: null,                                       // default
    styleClass: "",                                      // default
    actions: sap.m.MessageBox.Action.OK,                 // default
    emphasizedAction: sap.m.MessageBox.Action.OK,        // default
    initialFocus: null,                                  // default
    textDirection: sap.ui.core.TextDirection.Inherit     // default
});

If a callback is given, it is called after the alert dialog has been closed by the user via the OK button. The callback is called with the following signature:

  function (oAction)

where oAction can be either sap.m.MessageBox.Action.OK when the alert dialog is closed by tapping on the OK button or null when the alert dialog is closed by calling sap.m.InstanceManager.closeAllDialogs().

The alert dialog opened by this method is processed asynchronously. Applications have to use fnCallback to continue work after the user closed the alert dialog.

sap.m.MessageBox.confirm

Displays a confirmation dialog with the given message, a QUESTION icon, an OK button and a Cancel button. If a callback is given, it is called after the confirmation box has been closed by the user with one of the buttons.

sap.m.MessageBox.confirm("This message should appear in the confirmation", {
    title: "Confirm",                                    // default
    onClose: null,                                       // default
    styleClass: "",                                      // default
    actions: [ sap.m.MessageBox.Action.OK,
               sap.m.MessageBox.Action.CANCEL ],         // default
    emphasizedAction: sap.m.MessageBox.Action.OK,        // default
    initialFocus: null,                                  // default
    textDirection: sap.ui.core.TextDirection.Inherit     // default
});

The callback is called with the following signature

  function(oAction)

where oAction is set by one of the following three values: 1. sap.m.MessageBox.Action.OK: OK (confirmed) button is tapped. 2. sap.m.MessageBox.Action.CANCEL: Cancel (unconfirmed) button is tapped. 3. null: Confirm dialog is closed by calling sap.m.InstanceManager.closeAllDialogs()

The confirmation dialog opened by this method is processed asynchronously. Applications have to use fnCallback to continue work after the user closed the confirmation dialog

sap.m.MessageBox.error

Displays an error dialog with the given message, an ERROR icon, a CLOSE button.. If a callback is given, it is called after the error box has been closed by the user with one of the buttons.

sap.m.MessageBox.error("This message should appear in the error message box", {
    title: "Error",                                      // default
    onClose: null,                                       // default
    styleClass: "",                                      // default
    actions: sap.m.MessageBox.Action.CLOSE,              // default
    emphasizedAction: null,                              // default
    initialFocus: null,                                  // default
    textDirection: sap.ui.core.TextDirection.Inherit     // default
});

The callback is called with the following signature

  function (oAction)

The error dialog opened by this method is processed asynchronously. Applications have to use fnCallback to continue work after the user closed the error dialog.

sap.m.MessageBox.information

Displays an information dialog with the given message, an INFO icon, an OK button. If a callback is given, it is called after the info box has been closed by the user with one of the buttons.

sap.m.MessageBox.information("This message should appear in the information message box", {
    title: "Information",                                // default
    onClose: null,                                       // default
    styleClass: "",                                      // default
    actions: sap.m.MessageBox.Action.OK,                 // default
    emphasizedAction: sap.m.MessageBox.Action.OK,        // default
    initialFocus: null,                                  // default
    textDirection: sap.ui.core.TextDirection.Inherit     // default
});

The callback is called with the following signature *

  function (oAction)

The information dialog opened by this method is processed asynchronously. Applications have to use fnCallback to continue work after the user closed the information dialog

sap.m.MessageBox.show

Creates and displays an sap.m.Dialog with type sap.m.DialogType.Message with the given text and buttons, and optionally other parts. After the user has tapped a button, the onClose function is invoked when given.

The only mandatory parameter is vMessage. Either a string with the corresponding text or even a layout control could be provided.

sap.m.MessageBox.show("This message should appear in the message box", {
    icon: sap.m.MessageBox.Icon.NONE,                    // default
    title: "",                                           // default
    actions: sap.m.MessageBox.Action.OK,                 // default
    emphasizedAction: sap.m.MessageBox.Action.OK,        // default
    onClose: null,                                       // default
    styleClass: "",                                      // default
    initialFocus: null,                                  // default
    textDirection: sap.ui.core.TextDirection.Inherit     // default
});

The created dialog is executed asynchronously. When it has been created and registered for rendering, this function returns without waiting for a user reaction.

When applications have to react on the users choice, they have to provide a callback function and postpone any reaction on the user choice until that callback is triggered.

The signature of the callback is

function (oAction);

where oAction is the button that the user has tapped. For example, when the user has pressed the close button, an sap.m.MessageBox.Action.CLOSE is returned.

sap.m.MessageBox.success

Displays a success dialog with the given message, a SUCCESS icon, an OK button. If a callback is given, it is called after the success box has been closed by the user with one of the buttons.

sap.m.MessageBox.success("This message should appear in the success message box", {
    title: "Success",                                    // default
    onClose: null,                                       // default
    styleClass: "",                                      // default
    actions: sap.m.MessageBox.Action.OK,                 // default
    emphasizedAction: sap.m.MessageBox.Action.OK,        // default
    initialFocus: null,                                  // default
    textDirection: sap.ui.core.TextDirection.Inherit     // default
});

The callback is called with the following signature

  function(oAction)

The success dialog opened by this method is processed asynchronously. Applications have to use fnCallback to continue work after the user closed the success dialog

sap.m.MessageBox.warning

Displays a warning dialog with the given message, a WARNING icon, an OK button. If a callback is given, it is called after the warning box has been closed by the user with one of the buttons.

sap.m.MessageBox.warning("This message should appear in the warning message box", {
    title: "Warning",                                    // default
    onClose: null,                                       // default
    styleClass: "",                                      // default
    actions: sap.m.MessageBox.Action.OK,                 // default
    emphasizedAction: sap.m.MessageBox.Action.OK,        // default
    initialFocus: null,                                  // default
    textDirection: sap.ui.core.TextDirection.Inherit     // default
});

The callback is called with the following signature *

  function (oAction)

The warning dialog opened by this method is processed asynchronously. Applications have to use fnCallback to continue work after the user closed the warning dialog

sap.m.MessageBox.alert

Displays an alert dialog with the given message and an OK button (no icons).

sap.m.MessageBox.alert("This message should appear in the alert", {
    title: "Alert",                                      // default
    onClose: null,                                       // default
    styleClass: "",                                      // default
    actions: sap.m.MessageBox.Action.OK,                 // default
    emphasizedAction: sap.m.MessageBox.Action.OK,        // default
    initialFocus: null,                                  // default
    textDirection: sap.ui.core.TextDirection.Inherit     // default
});

If a callback is given, it is called after the alert dialog has been closed by the user via the OK button. The callback is called with the following signature:

  function (oAction)

where oAction can be either sap.m.MessageBox.Action.OK when the alert dialog is closed by tapping on the OK button or null when the alert dialog is closed by calling sap.m.InstanceManager.closeAllDialogs().

The alert dialog opened by this method is processed asynchronously. Applications have to use fnCallback to continue work after the user closed the alert dialog.

Param Type DefaultValue Description
vMessage string

Message to be displayed in the alert dialog. The usage of sap.core.Control as vMessage is deprecated since version 1.30.4.

mOptions object

Other options (optional)

onClose function

callback function to be called when the user closes the dialog

title string 'Alert'

Title to be displayed in the alert dialog

actions sap.m.MessageBox.Action sap.m.MessageBox.Action[] string string[] sap.m.MessageBox.Action.OK

Either a single action, or an array of actions. If no action(s) are given, the single action MessageBox.Action.OK is taken as a default for the parameter. Custom action(s) string or an array can be provided, and then the translation of custom actions needs to be done by the application.

emphasizedAction sap.m.MessageBox.Action string sap.m.MessageBox.Action.OK

Added since version 1.75.0. Specifies which action of the created dialog will be emphasized. EmphasizedAction will apply only if the property actions is provided.

id string

ID to be used for the alert dialog. Intended for test scenarios, not recommended for productive apps

styleClass string

Added since version 1.21.2. CSS style class which is added to the alert dialog's root DOM node. The compact design can be activated by setting this to "sapUiSizeCompact"

initialFocus string sap.m.MessageBox.Action

Added since version 1.28.0. initialFocus, this option sets the action name, the text of the button or the control that gets the focus as first focusable element after the MessageBox is opened. The usage of sap.ui.core.Control to set initialFocus is deprecated since version 1.30.4.

textDirection sap.ui.core.TextDirection

Added since version 1.28. Specifies the element's text directionality with enumerated options. By default, the control inherits text direction from the DOM.

verticalScrolling boolean

verticalScrolling is deprecated since version 1.30.4. VerticalScrolling, this option indicates if the user can scroll vertically inside the MessageBox when the content is larger than the content area.

horizontalScrolling boolean

horizontalScrolling is deprecated since version 1.30.4. HorizontalScrolling, this option indicates if the user can scroll horizontally inside the MessageBox when the content is larger than the content area.

details string

Added since version 1.28.0. If 'details' is set in the MessageBox, a link to view details is added. When the user clicks the link, the text area containing 'details' information is displayed. The initial visibility is not configurable and the details are hidden by default.

closeOnNavigation boolean true

Added since version 1.72.0. Whether the MessageBox will be closed automatically when a routing navigation occurs.

sap.m.MessageBox.confirm

Displays a confirmation dialog with the given message, a QUESTION icon, an OK button and a Cancel button. If a callback is given, it is called after the confirmation box has been closed by the user with one of the buttons.

sap.m.MessageBox.confirm("This message should appear in the confirmation", {
    title: "Confirm",                                    // default
    onClose: null,                                       // default
    styleClass: "",                                      // default
    actions: [ sap.m.MessageBox.Action.OK,
               sap.m.MessageBox.Action.CANCEL ],         // default
    emphasizedAction: sap.m.MessageBox.Action.OK,        // default
    initialFocus: null,                                  // default
    textDirection: sap.ui.core.TextDirection.Inherit     // default
});

The callback is called with the following signature

  function(oAction)

where oAction is set by one of the following three values: 1. sap.m.MessageBox.Action.OK: OK (confirmed) button is tapped. 2. sap.m.MessageBox.Action.CANCEL: Cancel (unconfirmed) button is tapped. 3. null: Confirm dialog is closed by calling sap.m.InstanceManager.closeAllDialogs()

The confirmation dialog opened by this method is processed asynchronously. Applications have to use fnCallback to continue work after the user closed the confirmation dialog

Param Type DefaultValue Description
vMessage string

Message to be displayed in the alert dialog. The usage of sap.core.Control as vMessage is deprecated since version 1.30.4.

mOptions object

Other options (optional)

onClose function

Callback to be called when the user closes the dialog

title string 'Confirmation'

Title to display in the confirmation dialog

actions sap.m.MessageBox.Action sap.m.MessageBox.Action[] string string[] sap.m.MessageBox.Action.OK

Either a single action, or an array of actions. If no action(s) are given, the single action MessageBox.Action.OK is taken as a default for the parameter. Custom action(s) string or an array can be provided, and then the translation of custom actions needs to be done by the application.

emphasizedAction sap.m.MessageBox.Action string sap.m.MessageBox.Action.OK

Added since version 1.75.0. Specifies which action of the created dialog will be emphasized. EmphasizedAction will apply only if the property actions is provided.

id string

ID to be used for the confirmation dialog. Intended for test scenarios, not recommended for productive apps

styleClass string

Added since version 1.21.2. CSS style class which is added to the confirmation dialog's root DOM node. The compact design can be activated by setting this to "sapUiSizeCompact"

initialFocus string sap.m.MessageBox.Action

Added since version 1.28.0. initialFocus, this option sets the action name, the text of the button or the control that gets the focus as first focusable element after the MessageBox is opened. The usage of sap.ui.core.Control to set initialFocus is deprecated since version 1.30.4.

textDirection sap.ui.core.TextDirection

Added since version 1.28. Specifies the element's text directionality with enumerated options. By default, the control inherits text direction from the DOM.

verticalScrolling boolean

verticalScrolling is deprecated since version 1.30.4. VerticalScrolling, this option indicates if the user can scroll vertically inside the MessageBox when the content is larger than the content area.

horizontalScrolling boolean

horizontalScrolling is deprecated since version 1.30.4. HorizontalScrolling, this option indicates if the user can scroll horizontally inside the MessageBox when the content is larger than the content area.

details string

Added since version 1.28.0. If 'details' is set in the MessageBox, a link to view details is added. When the user clicks the link, the text area containing 'details' information is displayed. The initial visibility is not configurable and the details are hidden by default.

closeOnNavigation boolean true

Added since version 1.72.0. Whether the MessageBox will be closed automatically when a routing navigation occurs.

sap.m.MessageBox.error

Displays an error dialog with the given message, an ERROR icon, a CLOSE button.. If a callback is given, it is called after the error box has been closed by the user with one of the buttons.

sap.m.MessageBox.error("This message should appear in the error message box", {
    title: "Error",                                      // default
    onClose: null,                                       // default
    styleClass: "",                                      // default
    actions: sap.m.MessageBox.Action.CLOSE,              // default
    emphasizedAction: null,                              // default
    initialFocus: null,                                  // default
    textDirection: sap.ui.core.TextDirection.Inherit     // default
});

The callback is called with the following signature

  function (oAction)

The error dialog opened by this method is processed asynchronously. Applications have to use fnCallback to continue work after the user closed the error dialog.

Param Type DefaultValue Description
vMessage string

Message to be displayed in the alert dialog. The usage of sap.core.Control as vMessage is deprecated since version 1.30.4.

mOptions object

Other options (optional)

onClose function

Callback when the user closes the dialog

title string 'Error'

Title of the error dialog

actions sap.m.MessageBox.Action sap.m.MessageBox.Action[] string string[] sap.m.MessageBox.Action.OK

Either a single action, or an array of actions. If no action(s) are given, the single action MessageBox.Action.OK is taken as a default for the parameter. Custom action(s) string or an array can be provided, and then the translation of custom actions needs to be done by the application.

emphasizedAction sap.m.MessageBox.Action string sap.m.MessageBox.Action.OK

Added since version 1.75.0. Specifies which action of the created dialog will be emphasized. EmphasizedAction will apply only if the property actions is provided.

id string

ID for the error dialog. Intended for test scenarios, not recommended for productive apps

styleClass string

CSS style class which is added to the error dialog's root DOM node. The compact design can be activated by setting this to "sapUiSizeCompact"

initialFocus string sap.m.MessageBox.Action

This option sets the action name, the text of the button or the control that gets the focus as first focusable element after the MessageBox is opened. The usage of sap.ui.core.Control to set initialFocus is deprecated since version 1.30.4.

textDirection sap.ui.core.TextDirection

Specifies the element's text directionality with enumerated options. By default, the control inherits text direction from the DOM.

verticalScrolling boolean

verticalScrolling is deprecated since version 1.30.4. VerticalScrolling, this option indicates if the user can scroll vertically inside the MessageBox when the content is larger than the content area.

horizontalScrolling boolean

horizontalScrolling is deprecated since version 1.30.4. HorizontalScrolling, this option indicates if the user can scroll horizontally inside the MessageBox when the content is larger than the content area.

details string

Added since version 1.28.0. If 'details' is set in the MessageBox, a link to view details is added. When the user clicks the link, the text area containing 'details' information is displayed. The initial visibility is not configurable and the details are hidden by default.

closeOnNavigation boolean true

Added since version 1.72.0. Whether the MessageBox will be closed automatically when a routing navigation occurs.

sap.m.MessageBox.information

Displays an information dialog with the given message, an INFO icon, an OK button. If a callback is given, it is called after the info box has been closed by the user with one of the buttons.

sap.m.MessageBox.information("This message should appear in the information message box", {
    title: "Information",                                // default
    onClose: null,                                       // default
    styleClass: "",                                      // default
    actions: sap.m.MessageBox.Action.OK,                 // default
    emphasizedAction: sap.m.MessageBox.Action.OK,        // default
    initialFocus: null,                                  // default
    textDirection: sap.ui.core.TextDirection.Inherit     // default
});

The callback is called with the following signature *

  function (oAction)

The information dialog opened by this method is processed asynchronously. Applications have to use fnCallback to continue work after the user closed the information dialog

Param Type DefaultValue Description
vMessage string

Message to be displayed in the alert dialog. The usage of sap.core.Control as vMessage is deprecated since version 1.30.4.

mOptions object

Other options (optional)

onClose function

Callback when the user closes the dialog

title string 'Information'

Title of the information dialog

actions sap.m.MessageBox.Action sap.m.MessageBox.Action[] string string[] sap.m.MessageBox.Action.OK

Either a single action, or an array of actions. If no action(s) are given, the single action MessageBox.Action.OK is taken as a default for the parameter. Custom action(s) string or an array can be provided, and then the translation of custom actions needs to be done by the application.

emphasizedAction sap.m.MessageBox.Action string sap.m.MessageBox.Action.OK

Added since version 1.75.0. Specifies which action of the created dialog will be emphasized. EmphasizedAction will apply only if the property actions is provided.

id string

ID for the information dialog. Intended for test scenarios, not recommended for productive apps

styleClass string

CSS style class which is added to the information dialog's root DOM node. The compact design can be activated by setting this to "sapUiSizeCompact"

initialFocus string sap.m.MessageBox.Action

This option sets the action name, the text of the button or the control that gets the focus as first focusable element after the MessageBox is opened. The usage of sap.ui.core.Control to set initialFocus is deprecated since version 1.30.4.

textDirection sap.ui.core.TextDirection

Specifies the element's text directionality with enumerated options. By default, the control inherits text direction from the DOM.

verticalScrolling boolean

verticalScrolling is deprecated since version 1.30.4. VerticalScrolling, this option indicates if the user can scroll vertically inside the MessageBox when the content is larger than the content area.

horizontalScrolling boolean

horizontalScrolling is deprecated since version 1.30.4. HorizontalScrolling, this option indicates if the user can scroll horizontally inside the MessageBox when the content is larger than the content area.

details string

Added since version 1.28.0. If 'details' is set in the MessageBox, a link to view details is added. When the user clicks the link, the text area containing 'details' information is displayed. The initial visibility is not configurable and the details are hidden by default.

closeOnNavigation boolean true

Added since version 1.72.0. Whether the MessageBox will be closed automatically when a routing navigation occurs.

sap.m.MessageBox.show

Creates and displays an sap.m.Dialog with type sap.m.DialogType.Message with the given text and buttons, and optionally other parts. After the user has tapped a button, the onClose function is invoked when given.

The only mandatory parameter is vMessage. Either a string with the corresponding text or even a layout control could be provided.

sap.m.MessageBox.show("This message should appear in the message box", {
    icon: sap.m.MessageBox.Icon.NONE,                    // default
    title: "",                                           // default
    actions: sap.m.MessageBox.Action.OK,                 // default
    emphasizedAction: sap.m.MessageBox.Action.OK,        // default
    onClose: null,                                       // default
    styleClass: "",                                      // default
    initialFocus: null,                                  // default
    textDirection: sap.ui.core.TextDirection.Inherit     // default
});

The created dialog is executed asynchronously. When it has been created and registered for rendering, this function returns without waiting for a user reaction.

When applications have to react on the users choice, they have to provide a callback function and postpone any reaction on the user choice until that callback is triggered.

The signature of the callback is

function (oAction);

where oAction is the button that the user has tapped. For example, when the user has pressed the close button, an sap.m.MessageBox.Action.CLOSE is returned.

Param Type DefaultValue Description
vMessage string

Message to be displayed in the alert dialog. The usage of sap.core.Control as vMessage is deprecated since version 1.30.4.

mOptions object

Other options (optional)

icon sap.m.MessageBox.Icon

The icon to be displayed.

title string

The title of the message box.

actions sap.m.MessageBox.Action sap.m.MessageBox.Action[] string string[] sap.m.MessageBox.Action.OK

Either a single action, or an array of actions. If no action(s) are given, the single action MessageBox.Action.OK is taken as a default for the parameter. Custom action(s) string or an array can be provided, and then the translation of custom actions needs to be done by the application.

emphasizedAction sap.m.MessageBox.Action string sap.m.MessageBox.Action.OK

Added since version 1.75.0. Specifies which action of the created dialog will be emphasized. EmphasizedAction will apply only if the property actions is provided.

onClose function

Function to be called when the user taps a button or closes the message box.

id string

ID to be used for the dialog. Intended for test scenarios, not recommended for productive apps

styleClass string

Added since version 1.21.2. CSS style class which is added to the dialog's root DOM node. The compact design can be activated by setting this to "sapUiSizeCompact"

initialFocus string sap.m.MessageBox.Action

Added since version 1.28.0. initialFocus, this option sets the action name, the text of the button or the control that gets the focus as first focusable element after the MessageBox is opened. The usage of sap.ui.core.Control to set initialFocus is deprecated since version 1.30.4.

textDirection sap.ui.core.TextDirection

Added since version 1.28. Specifies the element's text directionality with enumerated options. By default, the control inherits text direction from the DOM.

verticalScrolling boolean

verticalScrolling is deprecated since version 1.30.4. VerticalScrolling, this option indicates if the user can scroll vertically inside the MessageBox when the content is larger than the content area.

horizontalScrolling boolean

horizontalScrolling is deprecated since version 1.30.4. HorizontalScrolling, this option indicates if the user can scroll horizontally inside the MessageBox when the content is larger than the content area.

details string

Added since version 1.28.0. If 'details' is set in the MessageBox, a link to view details is added. When the user clicks the link, the text area containing 'details' information is displayed. The initial visibility is not configurable and the details are hidden by default.

contentWidth sap.ui.core.CSSSize

The width of the MessageBox

closeOnNavigation boolean true

Added since version 1.72.0. Whether the MessageBox will be closed automatically when a routing navigation occurs.

sap.m.MessageBox.success

Displays a success dialog with the given message, a SUCCESS icon, an OK button. If a callback is given, it is called after the success box has been closed by the user with one of the buttons.

sap.m.MessageBox.success("This message should appear in the success message box", {
    title: "Success",                                    // default
    onClose: null,                                       // default
    styleClass: "",                                      // default
    actions: sap.m.MessageBox.Action.OK,                 // default
    emphasizedAction: sap.m.MessageBox.Action.OK,        // default
    initialFocus: null,                                  // default
    textDirection: sap.ui.core.TextDirection.Inherit     // default
});

The callback is called with the following signature

  function(oAction)

The success dialog opened by this method is processed asynchronously. Applications have to use fnCallback to continue work after the user closed the success dialog

Param Type DefaultValue Description
vMessage string

Message to be displayed in the alert dialog. The usage of sap.core.Control as vMessage is deprecated since version 1.30.4.

mOptions object

Other options (optional)

onClose function

Callback when the user closes the dialog

title string 'Success'

Title of the success dialog

actions sap.m.MessageBox.Action sap.m.MessageBox.Action[] string string[] sap.m.MessageBox.Action.OK

Either a single action, or an array of actions. If no action(s) are given, the single action MessageBox.Action.OK is taken as a default for the parameter. Custom action(s) string or an array can be provided, and then the translation of custom actions needs to be done by the application.

emphasizedAction sap.m.MessageBox.Action string sap.m.MessageBox.Action.OK

Added since version 1.75.0. Specifies which action of the created dialog will be emphasized. EmphasizedAction will apply only if the property actions is provided.

id string

ID for the success dialog. Intended for test scenarios, not recommended for productive apps

styleClass string

CSS style class which is added to the success dialog's root DOM node. The compact design can be activated by setting this to "sapUiSizeCompact"

initialFocus string sap.m.MessageBox.Action

This option sets the action name, the text of the button or the control that gets the focus as first focusable element after the MessageBox is opened. The usage of sap.ui.core.Control to set initialFocus is deprecated since version 1.30.4.

textDirection sap.ui.core.TextDirection

Specifies the element's text directionality with enumerated options. By default, the control inherits text direction from the DOM.

verticalScrolling boolean

verticalScrolling is deprecated since version 1.30.4. VerticalScrolling, this option indicates if the user can scroll vertically inside the MessageBox when the content is larger than the content area.

horizontalScrolling boolean

horizontalScrolling is deprecated since version 1.30.4. HorizontalScrolling, this option indicates if the user can scroll horizontally inside the MessageBox when the content is larger than the content area.

details string

Added since version 1.28.0. If 'details' is set in the MessageBox, a link to view details is added. When the user clicks the link, the text area containing 'details' information is displayed. The initial visibility is not configurable and the details are hidden by default.

closeOnNavigation boolean true

Added since version 1.72.0. Whether the MessageBox will be closed automatically when a routing navigation occurs.

sap.m.MessageBox.warning

Displays a warning dialog with the given message, a WARNING icon, an OK button. If a callback is given, it is called after the warning box has been closed by the user with one of the buttons.

sap.m.MessageBox.warning("This message should appear in the warning message box", {
    title: "Warning",                                    // default
    onClose: null,                                       // default
    styleClass: "",                                      // default
    actions: sap.m.MessageBox.Action.OK,                 // default
    emphasizedAction: sap.m.MessageBox.Action.OK,        // default
    initialFocus: null,                                  // default
    textDirection: sap.ui.core.TextDirection.Inherit     // default
});

The callback is called with the following signature *

  function (oAction)

The warning dialog opened by this method is processed asynchronously. Applications have to use fnCallback to continue work after the user closed the warning dialog

Param Type DefaultValue Description
vMessage string

Message to be displayed in the alert dialog. The usage of sap.core.Control as vMessage is deprecated since version 1.30.4.

mOptions object

Other options (optional)

onClose function

Callback when the user closes the dialog

title string 'Warning'

Title of the warning dialog

actions sap.m.MessageBox.Action sap.m.MessageBox.Action[] string string[] sap.m.MessageBox.Action.OK

Either a single action, or an array of actions. If no action(s) are given, the single action MessageBox.Action.OK is taken as a default for the parameter. Custom action(s) string or an array can be provided, and then the translation of custom actions needs to be done by the application.

emphasizedAction sap.m.MessageBox.Action string sap.m.MessageBox.Action.OK

Added since version 1.75.0. Specifies which action of the created dialog will be emphasized. EmphasizedAction will apply only if the property actions is provided.

id string

ID to for the warning dialog. Intended for test scenarios, not recommended for productive apps

styleClass string

CSS style class which is added to the warning dialog's root DOM node. The compact design can be activated by setting this to "sapUiSizeCompact"

initialFocus string sap.m.MessageBox.Action

This option sets the action name, the text of the button or the control that gets the focus as first focusable element after the MessageBox is opened. The usage of sap.ui.core.Control to set initialFocus is deprecated since version 1.30.4.

textDirection sap.ui.core.TextDirection

Specifies the element's text directionality with enumerated options. By default, the control inherits text direction from the DOM.

verticalScrolling boolean

verticalScrolling is deprecated since version 1.30.4. VerticalScrolling, this option indicates if the user can scroll vertically inside the MessageBox when the content is larger than the content area.

horizontalScrolling boolean

horizontalScrolling is deprecated since version 1.30.4. HorizontalScrolling, this option indicates if the user can scroll horizontally inside the MessageBox when the content is larger than the content area.

details string

Added since version 1.28.0. If 'details' is set in the MessageBox, a link to view details is added. When the user clicks the link, the text area containing 'details' information is displayed. The initial visibility is not configurable and the details are hidden by default.

closeOnNavigation boolean true

Added since version 1.72.0. Whether the MessageBox will be closed automatically when a routing navigation occurs.