[英]How to wait for the response of an OData service's read operation in SAPUI5 before further execution of code?
[英]How to await the response of an OData service's read operation in SAPUI5?
里面有一個 OData 讀取調用,它是基於某些條件的多個導航。 僅對於其中一種情況,要求應完全從 OData 服務接收 OData 讀取調用的響應,然后才能進行導航。 OData 模型的版本是 2.0
在這種情況下我可以使用“ attachRequestCompleted ”嗎?
目前似乎正在發生的事情是正在導航視圖並且在此導航之后接收到數據。
請幫忙。 非常感謝!
一種方法是jQuery Deferred 。
myMethod: function(){
var oRouter = this.getRouter();
jQuery.when(
this.myRequest()
).then(function (sPage) {
oRouter.navTo(sPage);
});
},
myRequest: function(){
var RequestDeferred = jQuery.Deferred();
var oModel = this.getModel();
oModel.read("/myEntity", {
success: function(oResponse){
//do something
RequestDeferred.resolve(oResponse.page); //Calls "then" in myMethod
}
});
return RequestDeferred;
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.