cancel
Showing results for 
Search instead for 
Did you mean: 

Startup optimization - MetaData load seems to be Synchronous

joao_sousa2
Active Contributor
0 Kudos

Hello,

I'm trying to optimize the startup time of my app, and (app)CacheBuster solves most of the problems, but I'm still unhappy with the metadata load which I can't seem to make asynchronous.

In component.js I'm calling this:

this.setModel(new sap.ui.model.odata.ODataModel(sServiceUrl, true, null, null, null, false, true).attachMetadataLoaded(this, this._onMetaLoad));

But I'm getting this timeline in Chrome:

The List.view.xml is the first view loaded by the component according to the router, but it seems to wait until the metadata load is finished before it is retrieved. The last "true" in the model creation should be setting it to asynchronous, and if I break point the code, the next instruction does run before the metadata is returned.

It seems to be asynchronous but apparently it is blocking the loading of the next element. Which is even stranger since the oData service is connection to an ECC while the SAPUI5 is running in a local web server.

Any ideas?

Thanks

Accepted Solutions (1)

Accepted Solutions (1)

former_member182372
Active Contributor
0 Kudos

you mised one more parameter

var ODataModel = Model.extend("sap.ui.model.odata.ODataModel", /** @lends sap.ui.model.odata.ODataModel.prototype */ {

-?                                (sServiceUrl, true,      null,     null,            null,            false,                    true                       ????????    )

constructor : function(sServiceUrl, bJSON, sUser, sPassword, mHeaders, bTokenHandling, bWithCredentials, bLoadMetadataAsync) {

that's why we use json settings

sServiceUrl, {

...

loadMetadataAsync : true,

....

}

joao_sousa2
Active Contributor
0 Kudos

You're right, counted multiple times and still got it wrong. Using JSON for parameters is an "alien" concept for someone coming from a typed language, but I do see why it is safer.

In Javascript you have a signature that you can "ignore", it's quite strange.

Thanks.

Qualiture
Active Contributor
0 Kudos

If you're using WebStorm, it may give you a warning stating the number of parameters does not match the expectation (although it sometimes states 'expected: 0' incorrectly in some rare cases)

former_member182372
Active Contributor
0 Kudos

to me it smells very much like abap FM call - named input parameters

Answers (2)

Answers (2)

joao_sousa2
Active Contributor
0 Kudos

It goes half way. You put one parameter outside the brackets and then named ones inside the brackets.

former_member104848
Participant
0 Kudos

Hello Joao,

What version of SAPUI5 are you using ?

The API doc here : JsDoc Report - SAP UI development Toolkit for HTML5 - API Reference - sap.ui.model.odata.ODataModel , the 8th parameter that you send while instantiating the oData Model determines whether the metadat call is sync/async.

{object}bLoadMetadataAsync?

(optional) determined if the service metadata request is sent synchronous or asynchronous. Default is false. Please note that if this is set to true attach to the metadataLoaded event to get notified when the metadata has been loaded before accessing the service metadata.


By default the metedata is loaded sysnchronously. Please pass the highlited parameter and check.

this.setModel(new sap.ui.model.odata.ODataModel(sServiceUrl, true, null, null, null, false,true, true).attachMetadataLoaded(this, this._onMetaLoad));


Best Regards,

Radhika