Skip to Content
0

how to set busy state while loading metadata

Mar 02 at 06:59 AM

112

avatar image

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

10 |10000 characters needed characters left characters exceeded

I guess this link could be accessed on extranet :)

https://experience.sap.com/fiori-design-web/busy-handling/

0
* Please Login or Register to Answer, Follow or Comment.

4 Answers

Emanuele Ricci Mar 02 at 09:10 AM
0

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
Show 1 Share
10 |10000 characters needed characters left 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.

0
Emanuele Ricci Mar 02 at 11:04 AM
0

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

Show 1 Share
10 |10000 characters needed characters left 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."

0
Nicholas Owen O’Malley Mar 05 at 07:53 AM
0

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.

Share
10 |10000 characters needed characters left characters exceeded
Jun Wu Mar 05 at 08:49 PM
0
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.

Share
10 |10000 characters needed characters left characters exceeded