Skip to Content

how to set busy state while loading metadata

Dear all,

I'm working on a master-detail app which uses flexColumnLayout. I want to add busy handling according to the guideline (https://ux.wdf.sap.corp/fiori-design-web/busy-handling/): set page busy while loading metadata and not busy after loading. I have no idea inside which function to call setBusy(). Do you have any idea?

Thank you very much in advance :)

Best Regards,

Ying

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

4 Answers

  • Mar 02 at 09:10 AM

    Hi Ying, I think that the link you just shared is available only on your intranet ;)

    So, let's start from the beginning. Every control that extends sap.ui.core.Control (probably 99% of controls and custom controls ;) ) will allow you to handle the busy state.

    If you want, you can handle the global busy state of the page like this:

    Show a busy indicator

    sap.ui.core.BusyIndicator.show(<number of ms>);

    hide a busy indicator

    sap.ui.core.BusyIndicator.hide();

    Usually, the rule of thumb to know when you have to show/hide a busy indicator is:

    • Show it before every oDataModel read/bindItems
    • Hide it on the success/error call back
    Add comment
    10|10000 characters needed characters exceeded

    • Hi Emanuele,

      Thank you for your reply :P

      I want to set the whole page busy when I start the app, and set it free after the odata metadata is loaded.The metadata request is called automatically. It's not the same as the odata regular call which you know where you call it.

  • Mar 02 at 11:04 AM

    So for the first part is easy, you have just need to

    sap.ui.core.BusyIndicator.show(<numberofms>);

    on your Component.js

    For the second party, maybe I would need to know why you want to wait for the metadata call. Usually, inside the metadata, you don't have real data but only metadata, so the user is not served with something to show.

    Can you explain a little bit more your scenario?

    Anyway, you can hide the busy loading on the metadataLoaded event. You just need to attach it to the oDataModel (v2) using this API: https://openui5.hana.ondemand.com/#/api/sap.ui.model.odata.v2.ODataModel/methods/attachMetadataLoaded

    Add comment
    10|10000 characters needed characters exceeded

    • Dear Emanuele,

      I found the link on extranet: https://experience.sap.com/fiori-design-web/busy-handling/

      The scenario is: "First, the UI description and metadata are loaded. This is the minimum for a basic functional UI. Until this data is available, the app UI needs to be blocked. Once the metadata has been loaded, we can partially unblock the UI where it makes sense. The busy state is set for the master list and the details area until the data has been loaded. Once the data for the master list area is available, the busy state is removed. Because the data for the details area is loaded asynchronously, its busy state is set separately."

  • Mar 05 at 07:53 AM

    Hello Ying Wang

    First you need to find the wrapper you want to have a busy indicator.

    If you want a table eks:

    var table = this.getView().byId("tableId");
    Then you can sett the busy indicator on the table:
    table.setBusy(true);

    Then for the second part you need to know when the call is done. There are some ways of knowing that, usaly with a promise.

    If it is a promise / you can create a promise you can do something like this:
    getSomeDataFunc: function(){
        return new Promise(function(resolve, reject) {
            var oModel = new sap.ui.model.odata.ODataModel({
    	    serviceUrl: "/sap/opu/odata/sap/SERVICE_NAME/",
                json: true
     	 });
    
    oModel.read(sPath, null, null,
        function(oData) {                 
            //I got the data and i am returning it
    	resolve(oData);
        },
        function(oError) {
            //Something went wrong, here is the error msg
            reject(oError);
        });
    
    }
    }
    
    this.getSomeDataFunc().then(function(data){
        //I now know the data fetching is done and i will do my biding!
        table.setBusy(false);
    })

    If you are getting the data when the view is loaded, you want to do this in the onInit: function(){} You also want to grab the view id not a table ID.

    Add comment
    10|10000 characters needed characters exceeded

  • Mar 05 at 08:49 PM
    attachBatchRequestSent

    Attach event-handler fnFunction to the requestSent event of this sap.ui.model.odata.v2.ODataModel.

    attachBatchRequestCompleted

    Attach event-handler fnFunction to the batchRequestCompleted event of this sap.ui.model.odata.v2.ODataModel.

    try those two.

    Add comment
    10|10000 characters needed characters exceeded