Posts

Classes in UI5

Classes in UI5 How to extend sap.ui.base.Object So here’s a very basic template for extending the sap.ui.base.Object. sap . ui . define ( [ "sap/ui/base/Object" , "sap/base/Log" ] , function ( Object , Log ) { "use strict" ; return Object . extend ( "XXX.control.XXX" , { /** * @class XXX * @summary Example of an sap.ui.base.Object */ constructor : function ( oController ) { this . _oParentController = oController ; this . _oServiceModel = oController . getView ( ) . getModel ( ) ; Log . info ( "Object initialized" ) ; } , /** * @memberOf XXX * @description getXXX */ getXXX : function ( ) { } , /** * @memberOf XXX * @description setXXX */ setXXX : function ( ) { } } ) ; } ) ; I always pass the “this” context in the constructor ...

Batch request

Batch request Batch request A batch request allows us grouping multiple operations in one single request. batch mode has to be enabled for this. You can do this by enabling it via the function setUseBatch this . _oServiceModel . setUseBatch ( true ) ; or in your manifest.json "" : { "dataSource" : "mainService" , "preload" : true , "settings" : { "useBatch" : true } } So here’s a coding sample with an batchGroupId sampleBatchRequest : function ( ) { //Get all GroupId's var aDeferredGroup = this . _oServiceModel . getDeferredGroups ( ) ; //Add a new Group Id aDeferredGroup . push ( "doSomething" ) ; this . oServiceModel . setDeferredGroups ( aDeferredGroup ) ; //Create Parameters var oParameters = { groupId : "doSomething" } ;...

F4 Helper JSONModel

F4_Helper_JSONModel.md F4 Helper JSON Model Often there is data you only need to load once at runtime. For example: Languages Countrys Titles Departments … For this data you often need formatters to convert the key to the value. In the following I will show you how I deal with these “F4 Key Value Datasets”. model/TitleF4.js The JSONModel is pretty simple. We have a method to load the data aswell as a method that converts keys to values. sap . ui . define ( [ "sap/ui/model/json/JSONModel" ] , function ( JSONModel ) { return JSONModel . extend ( "XXX.model.TitleF4" , { /** * @class TitleF4 * @summary TitleF4 Help. Will be loaded once at runtime * @extends sap.ui.model.json.JSONModel * @example * this.setModel( new TitleF4(this), "TitleF4"); */ constructor : function ( controller ) { JSONModel . prototype . constructor . call ( this , [ ] ) ; this . _oParentController = co...

How to extend a JSONModel

How to extend a JSONModel How to extend a JSONModel So here’s a very basic template for extending the JSONModel. sap . ui . define ( [ "sap/ui/model/json/JSONModel" , "sap/base/Log" ] , function ( JSONModel , Log ) { return JSONModel . extend ( "XXX.model.XXX" , { /** * @class XXX * @summary XXX * @extends sap.ui.model.json.JSONModel * @param {Object} controller - this * @example * this.setModel( new XXX(this), "XXX"); */ constructor : function ( controller ) { JSONModel . prototype . constructor . call ( this , [ ] ) ; this . _oParentController = controller || void 0 ; this . _oServiceModel = this . _oParentController . getModel ( ) ; Log . info ( "XXX.js initialized" ) ; } , /** * @memberOf XXX * @description XXX * @example * this.getModel("XXX").getXXX(); */ getXXX : function ( ) { } } ) ; }...