cancel
Showing results for 
Search instead for 
Did you mean: 

attachRequestCompleted behaviou

Former Member
0 Kudos

Hi Guys,

I implemented an ODate request and attached a RequestSent and a RequestCompleted eventhandler. The first calls a function to show a BusyDialog and the second one calls a function to close the BusyDialog.

The request has the following timing:

The waiting time can be something between 7s and 15s (I know that this is quite some time^^).

My Problem is, that the SDK states the following:

The 'requestCompleted' event is fired, after a request has been completed (includes receiving a response), no matter whether the request succeeded or not.

In my opinion this means, that my RequestCompleted event would be called after the waiting and download time. Strangely though, it gets called right away and I do not see any BusyDialog.


This is some of my code:


var model = sap.ui.getCore().getModel();

  model.attachRequestSent(view.getController().handleRequestSent());

  model.attachRequestCompleted(view.getController().handleRequestCompleted())


handleRequestSent : function () {

  bs = new sap.m.BusyDialog("busybusy");

  bs.placeAt("content");

  bs.open();

  },

handleRequestCompleted : function () {

  bs = sap.ui.getCore().byId("busybusy");

  bs.close();

  bs.destroy();

  }

Can anybody explain this behaviour to me ?

Thanks

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hello Maksim and Sergio,

thank you for your answers. I already tried different approaches to show a busy state but none of them worked because of my main problem:

The function handleRequestCompleted() gets called right away but I expect it to be called after the waiting time and the content download time because in my mind this is the point where the request is completed.

Somehow though the SAPUI5 framework thinks the request is completed after "request sent" and thus I do not see any BusyIndicator but I am still waiting some seconds to get some data.

I hope you can understand my problem. There is nothing wrong with my BusyIndicator or BusyDialog but with the time at which the requestCompleted event is triggered.

former_member182372
Active Contributor
0 Kudos

ODataModel fires RequestCompleted event in 3 places and only one of them is for successfull call.

handleRequestCompleted : function (evt) {

//evt.success - if true

  this.bs.close();

}

Former Member
0 Kudos

Hi Maksim,

thanks for you answer. I assume it is correct but right now I can't figure out how to pass evt to the function.

former_member182372
Active Contributor
0 Kudos

that.fireRequestCompleted({url : oRequest.requestUri, type : "GET", async : oRequest.async, info: "Accept headers:" + that.oHeaders["Accept"], infoObject : {acceptHeaders: that.oHeaders["Accept"]}, success: true});

ODataModel will take care of it, it is a call back handler. Do you see parameter coming to handleRequestCompleted ?

former_member182372
Active Contributor
0 Kudos

btw, i prefer to use DataReceived from the binding instead of global model requestComplete event (it is executed with every call)

Answers (2)

Answers (2)

former_member182372
Active Contributor
0 Kudos

Couple points

1) sap.ui.model.Model has attachRequestFailed event

2) As mentioned by Sergio, don't create new dialog every time request is sent, have is as a variable of controller


var model = sap.ui.getCore().getModel(); 

model.attachRequestSent(view.getController().handleRequestSent()); 

model.attachRequestCompleted(view.getController().handleRequestCompleted()) 

..........

//Controller

..........

bs : new sap.m.BusyDialog("busybusy"),

handleRequestSent : function () { 

  this.bs.open(); 

}, 

handleRequestCompleted : function () { 

  this.bs.close(); 

SergioG_TX
Active Contributor
0 Kudos

Nils,

it looks like you create the new busyDialog object everytime you come into the event handler. so the object busybusy may get duplicate id error or possible a different id assigned by the framework to avoid collisions..

I am not sure if you have to do a place At.. then open... you could try simply opening it.. or another suggestion would be to try:

sap.ui.core.BusyIndicator.show()

sap.ui.core.BusyIndicator.hide()

hope this helps