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

UI5
Paper dialog boxes on gray background with blank empty copy space.

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

Most Recent Articles

Will SAP UI5 replace the SAP Web UI?

SAP Full Forms

More Similar Articles

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