7

I made a Master-Detail application in Web IDE with SAPUI5.

I connected my application to an OData service (V2). The connection parameters have been stored in manifest.json.

I want to prevent my UI5 application from using $batch requests.

I know how to use the following code to disable batch request for a particular request:

var oDataModel = this.getModel(); // sap.ui.model.odata.v2.ODataModel
oDataModel.setUseBatch(false);

But the problem is that I can not use this in onInit function.

Can I set some parameter in manifest.json to disable batch request in general and even when the program is loading it does not use $batch?

3 Answers 3

18

You should be able to add parameter useBatch to the settings of your model. According to the documentation (section /sap.ui5/models) these settings will be passed to the constructor.

{
  "sap.ui5": {
    "models": {
      "yourV2ODataModel": {
        "dataSource": "yourDataSource",
        "settings": {
          "useBatch": false
        }
      }
    }
  }
}

The availability of component models in onInit has been discussed here several times. See the application init process to see why they are not available.

0
0

Well you could to it in the onInit function. But like this:

var oDataModel = this.getOwnerComponent().getModel();

oDataModel.setUseBatch(false);
1
  • 3
    hi, setting properties of a model that is defined in manifest.json is not considered good idea. imagine the model being replaced by a mockservers model or what not. the correct answer is already given, and is to set the models settings in the manifest.json Jan 5, 2021 at 16:27
0

Go to Component.js

on its "init" method:

this.getModel("yourDesiredModel").setUseBatch(false)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.