Namespace sap.ui.commons.MessageBoxModule: sap/ui/commons/MessageBox
Provides methods to create standard alerts, confirmation dialogs, or arbitrary message boxes.
As MessageBox
is a static class, a jQuery.sap.require("sap.ui.commons.MessageBox");
statement must be explicitly executed before the class can be used. Example:
jQuery.sap.require("sap.ui.commons.MessageBox"); sap.ui.commons.MessageBox.show( "This message should appear in the message box.", sap.ui.commons.MessageBox.Icon.INFORMATION, "My message box title", [sap.ui.commons.MessageBox.Action.YES, sap.ui.commons.MessageBox.Action.NO], function() { / * do something * / } );
Deprecated API:Since version 1.38. Instead, use the sap.m.MessageBox
control.
Since: 0.8.8.
function ()
The alert box opened by this method is modal and it is processed asynchronously. Applications have to use the fnCallback
to continue work after the user closed the alert box.
{string|sap.ui.core.Control} | vMessage | Message to be displayed in the alert box |
{function} | fnCallback? | callback function to be called when the user closed the dialog |
{string} | sTitle? | Title to be displayed in the alert box |
{string} | sDialogId? | ID to be used for the alert box. Intended for test scenarios, not recommended for productive apps |
function(bConfirmed)
where bConfirmed is set to true when the user has activated the OK button.
The confirmation dialog box opened by this method is modal and it is processed asynchronously. Applications have to use the fnCallback
to continue work after the user closed the alert box.
{string|sap.ui.core.Control} | vMessage | Message to display |
{function} | fnCallback? | Callback to be called |
{string} | sTitle? | Title to display |
{string} | sDialogId? | ID to be used for the confirmation dialog. Intended for test scenarios, not recommended for productive apps |
callback
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.
The created dialog box 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 pressed. When the user has pressed the close button, a MessageBox.Action.Close is returned.
{string|sap.ui.core.Control} | vMessage | The message to be displayed. |
{sap.ui.commons.MessageBox.Icon} | oIcon?, Default: None | The icon to be displayed. |
{string} | sTitle?, Default: '' | The title of the message box. |
{sap.ui.commons.MessageBox.Action|sap.ui.commons.MessageBox.Action[]} | vActions? | 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. |
{function} | fnCallback? | Function to be called when the user has pressed a button or has closed the message box. |
{sap.ui.commons.MessageBox.Action} | oDefaultAction? | Must be one of the actions provided in vActions. |
{string} | sDialogId? | ID to be used for the dialog. Intended for test scenarios, not recommended for productive apps |