How to Use the Internalization i18n Model in a Dialog in SAP UI5?

UI5

It is possible to use the internalization i18n model in a sap.m.Dialog as well. You just need to add the dialog to the dependent aggregation of the sap.ui.core.mvc.View of the dialog:

<!-- view -->
<mvc:View
  controllerName="foo.controller.Controller"
  xmlns:mvc="sap.ui.core.mvc"
  xmlns="sap.m">

    <Button text="Dialog" press="onDialogPress"/>

</mvc:View>
// controller
sap.ui.define([
  "sap/ui/core/mvc/Controller"
], function(Controller) {
  "use strict";
  
  return Controller.extend("foo.controller.Controller", function() {
  
    _openDialog: function() {
     
      if (!this.oDialog) {         
    
        // instantiate dialog if no dialog exist 
        this.oDialog = new Dialog();     

      }

      // add the dialog as dependent to the view     
      this.getView().addDependent(this.oDialog);     
      this.oDialog.open(); 

    }
  
});

After you added the dialog to the dependent aggregation of the view the internalization i18n model is available in the dialog.

No Comments

FREE SAP Modules Overview! (Complete)

Plus, receive all future infographics and SAP tips & insights that are only shared with the private newsletter subscribers. 

Latest Poll
Essential Ressources

Leave a Reply

Your email address will not be published. Required fields are marked *

Fill out this field
Fill out this field
Please enter a valid email address.

Menu