SAP OData 的 V2 模型
文檔地址:
https://sapui5.hana.ondemand.com/#/topic/6c47b2b39db9404582994070ec3d57a2#loio66a130fa4d10411b8fc90df00185554b
The OData model is a server-side model, meaning that the data set is only available on the server and the client only knows the currently visible (requested) data. Operations, such as sorting and filtering, are done on the server. The client sends a request to the server and shows the returned data.
OData 模型是一個服務(wù)器端模型,這意味著業(yè)務(wù)數(shù)據(jù)只在服務(wù)器端可用,客戶端只維護了其當前發(fā)出請求后,服務(wù)器端返回的部分數(shù)據(jù)。圍繞數(shù)據(jù)進行的排序和過濾等操作,都是先在服務(wù)器端執(zhí)行,再將執(zhí)行結(jié)果返回給客戶端。
Requests to the back end are triggered by list bindings (ODataListBinding), context bindings (ODataContextBinding), and CRUD functions provided by the ODataModel. Property bindings (ODataPropertyBindings) do not trigger requests.
目前 OData 模型通過如下 API 觸發(fā)向后臺的數(shù)據(jù)請求:
- List binding - ODataListBinding
- context binding - ODataContextBinding
- 增刪改查操作
The following two versions of the OData model are implemented:
- sap.ui.model.odata.ODataModel
- sap.ui.model.odata.v2.ODataModel.
The v2.ODataModel has an improved feature set and new features will only be implemented in this model.
sap.ui.model.odata.ODataModel is deprecated. We recommend to only use v2.ODataModel.
前者已經(jīng)被標注成 deprecated 狀態(tài),后者是 SAP 推薦使用的數(shù)據(jù)模型。
注意:OData V2 模型已經(jīng)支持客戶端的排序和過濾了。
OData model 模型實例的創(chuàng)建方法:
var oModel = new ODataModel("http://services.odata.org/Northwind/Northwind.svc/"); var oModel = new ODataModel({serviceUrl: "http://services.odata.org/Northwind/Northwind.svc"});當模型實例創(chuàng)建時,自動觸發(fā)獲取 OData 服務(wù)元數(shù)據(jù)的請求:
http://services.odata.org/Northwind/Northwind.svc/$metadata
Only the first model instance triggers a $metadata request. A JSON representation of the service metadata can be accessed by calling the getServiceMetadata() method on an OData model instance.
JSON 格式的服務(wù)元數(shù)據(jù),通過模型實例的 getServiceMetadata 方法返回。
var oMetadata = oModel.getServiceMetadata();In the v2.ODataModel, the service metadata is loaded asynchronously. It is not possible to load it synchronously. To get notified when the loading is finished, attach the metadataLoaded event.
對于 2.0 版本的 OData 模型來說,服務(wù)元數(shù)據(jù)采取一部方式加載,如果在應(yīng)用程序里想捕捉元數(shù)據(jù)加載成功的事件,需要監(jiān)聽 metadataLoaded 事件。
總結(jié)
以上是生活随笔為你收集整理的SAP OData 的 V2 模型的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 银行卡被风控了有什么影响 银行卡被风控了
- 下一篇: 如何处理使用 SAP UI5 消费真实的