Skip to Content

How to show busy indicator for create request in sap ui5?

Dear GreatMinds,

I struck up with opening busydailog when calling the create request(synchronous) .I tried

oModel.attachRequestSent(function(){

myBusyDialog.open();

});


oModel.attachRequestCompleted(function(){

myBusyDialog.close();

});

and

myBusyDialog.open();

oModel.create('/entity', ovalue, null,

function(res) {myBusyDialog.close();},

function(res){myBusyDialog.close();})

But both are not working in my case.

Please do the needful.

Thanks In Advance.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

5 Answers

  • Posted on Dec 16, 2014 at 12:07 PM

    Hi,

    I think I know what the issue is here. You might be getting multiple "requestCompleted" events fired. So, request 1 (opens the dialog), request 2, response 1 (closes dialog), response 2 (the one you are interested in). This could be caused by the CSRF token for example.

    What I usually do with the the busy loader is count how many requests go out and only close the busy dialog when we have all responses in, something like the following (untested and coded here so be warned!):

    var myCounter = 0;
    
    model.attachRequestSent(function() {
    myBusyDialog.open();
    myCounter += 1;
    ));
    
    model.attachRequestCompleted(function() {
        if (myCounter>1) {
            myCounter -= 1;
        }    
        if (myCounter == 0) {
            myBusyDialog.close();
        }
    ));
    

    Remember also to attach something to the requestFailed event (perhaps a nice sap.m.Dialog to display the error) and also to fire the same function for request completed. This usually ends up in its own utility object in my projects, constructed by passing in a model object so that we only have one busy dialog & one counter mechanism even if we have multiple models.

    Hope this helps,

    Oli

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Dec 15, 2014 at 09:17 AM

    Can you share how you have instantiated your BusyDialog?

    Do you see any errors in the console?

    Add a comment
    10|10000 characters needed characters exceeded

    • Hi Robin,

      I am not getting any errors in console...

      here I am sharing my code...

      myBusyDialog = new sap.m.BusyDialog({

      showCancelButton : false,

      });

      sendrf:function(oeve){

      var sservice = "/sap/opu/odata/sap/---_SRV";

      var oModel = new sap.ui.model.odata.ODataModel(sservice,true);

      oModel.attachRequestSent(function(){

      myBusyDialog.open();

      });

      oModel.attachRequestCompleted(function(){

      myBusyDialog.close();

      });

      oModel.create('/sendtorfSet', ovalue, null,

      function(res) { ----},

      function(res){-----});

      }

      For Query operations this code is working fine, but I am not able to get busy dialog for Create Request.

      I searched Many sites, all are suggesting open the busydialog by keeping default timeout... But its not solving my problem.

  • Posted on Dec 15, 2014 at 11:26 AM

    Try commenting the myBusyDialog.close();

    So that application will display busy dialog all the time and if you find any errors in console, do share.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Dec 15, 2014 at 12:40 PM

    request could have completed quickly. So only you were not able to see the dialog.

    Use timer event function and try put the dialog close inside the function. You will be able to see the dialog.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Dec 16, 2014 at 12:16 PM
    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.