new sap.ui.commons.Dialog()). Next, you set the properties for the title and the content, make settings for the size and define other property values.alert(), confirm(), and show(). 



<!DOCTYPE HTML>
<html>
<head>
<title>Welcome | SAPUI5 Demo ::Dialog controls</title>
<script src="resources/sap-ui-core.js" id="sap-ui-bootstrap"
data-sap-ui-libs="sap.ui.commons"
data-sap-ui-theme="sap_goldreflection">
// Available Themes: sap_goldreflection, sap_platinum and By Default: High Contrast Black
</script>
<!-- add sap.ui.table,sap.ui.ux3 and/or other libraries to 'data-sap-ui-libs' if required -->
<script>
function dispAlert() { //Display simple Alert Message
sap.ui.commons.MessageBox.confirm("Are you want to display message?",rCallAlertBack, "Confirmation");
return false;
}
// to call the above function, we create a simple button
new sap.ui.commons.Button({text:"Show Message", press : dispAlert}).placeAt("content1");
// to get back the user selection from the above function
function rCallAlertBack(rValue) {
if(rValue) //If User presses 'Ok'
{
sap.ui.commons.MessageBox.alert("Welcome to SAPUI5.\n You're now viewing a Simple alert message.",'',"Congrats!");
return false;
}
else // If the user presses 'Cancel'
{
sap.ui.commons.MessageBox.alert("You are refussed to display the message",'',"Notification");
}
}
jQuery.sap.require("sap.ui.commons.MessageBox"); // this is required since there is no direct access to the box's icons like MessageBox.Icon.WARNING
function fnCallbackMessageBox1(sResult1) {
if(sResult1=='OK') {
sap.ui.commons.MessageBox.show("You are not authorized to delete this content.\n Please check your access",
sap.ui.commons.MessageBox.Icon.WARNING,
"Warning",
[sap.ui.commons.MessageBox.Action.OK,sap.ui.commons.MessageBox.Action.CANCEL],
'', sap.ui.commons.MessageBox.Action.OK);
}
else {
sap.ui.commons.MessageBox.alert("You are refused to display the message",'',"Notification");
}
return true;
}
// a callback that will be called when the message box is closed again
function fnCallbackMessageBox(sResult) {
if(sResult=='OK') {
sap.ui.commons.MessageBox.show("You are not authorized to delete this content.\nCheck Access and try again",
sap.ui.commons.MessageBox.Icon.INFORMATION,
"Notification", [sap.ui.commons.MessageBox.Action.OK,sap.ui.commons.MessageBox.Action.CANCEL],
fnCallbackMessageBox1, sap.ui.commons.MessageBox.Action.OK);
}
else {
sap.ui.commons.MessageBox.show("Data deleted successfully!\n", sap.ui.commons.MessageBox.Icon.SUCCESS,"Sucess",
[sap.ui.commons.MessageBox.Action.OK], '', [sap.ui.commons.MessageBox.Action.OK]);
}
return true;
}
function openMessageBox() {
/* sap.ui.commons.MessageBox.Icon.WARNING or ERROR or INFORMATION OR CRITICAL OR SUCCESS OR QUESTION
For the buttons to be displayed, you can use values such as sap.ui.commons.MessageBox.Action.YES or sap.ui.commons.MessageBox.Action.NO. */
// open a fully configured message box
sap.ui.commons.MessageBox.show("You are not authorized to delete this content.\nCheck Access and try again",
sap.ui.commons.MessageBox.Icon.ERROR,"Error",
[sap.ui.commons.MessageBox.Action.OK,sap.ui.commons.MessageBox.Action.RETRY],
fnCallbackMessageBox,
[sap.ui.commons.MessageBox.Action.OK,sap.ui.commons.MessageBox.Action.RETRY]);
}
// to call the above function, we create a simple button
new sap.ui.commons.Button({text:"Delete Content", press : openMessageBox}).placeAt("Content2");
</script>
</head>
<body class="sapUiBody">
<div id="content1"></div>
<br/>
<div id="Content2"></div>
<br/>
</body>
</html>





You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 3143 | |
| 1916 | |
| 1916 | |
| 1213 | |
| 1079 | |
| 757 | |
| 755 | |
| 742 |