Attila, S/4HANA, BTP Fullstack Developer (EN, DE, HU)
Popup to Confirm in SAPUI5 Fiori
Save time and have much clearer coding instead of implementing specialized confirmation Dialogs in Fiori / SAPUI5.
- fnOK: callback function in the controller to invoke, when user press OK button in confirmation Dialog
- aArguments: an array with parameters to be passed for fnOK
- si18nTitle: i18n identifier of the text in the resourcebundle file (i18n.properties) to be shown as Dialog Title
- si18nText: i18n identifier of the text in the resourcebundle file (i18n.properties) to be shown as Message Text
sap.ui.define([
"sap/ui/core/mvc/Controller",
"sap/m/MessageBox",
], function(Controller, MessageBox ) {
"use strict";
return Controller.extend("My.controller.Example", {
onInit: function() {
// Global references
this._oComponent = sap.ui.core.Component.getOwnerComponentFor(this.getView());
this._oText = this._oComponent.getModel("i18n").getResourceBundle();
},
/**
* Generic Confirmation Dialog for reuse
* @param fnOK
* @param aArguments
* @param si18nTitle
* @param si18nText
*/
openConfirmDialog: function(fnOK, aArguments, si18nTitle, si18nText) {
MessageBox.show(
this._oText.getText(si18nText), {
icon: MessageBox.Icon.QUESTION,
title: this._oText.getText(si18nTitle),
actions: [MessageBox.Action.YES, MessageBox.Action.NO],
onClose: function(sAnswer) {
if (sAnswer === MessageBox.Action.YES) {
fnOK.apply(this, aArguments);
}
}
}
);
}
});
});


