0
如何配置manifest.json文件,以便當我運行mockserver(mockserver.html)然後它轉到本地json數據,並且當我運行index.html(主入口到應用程序)時,到遠程服務。我從文檔中獲取了一個樣本manifest.json文件,但不太清楚遠程和本地服務如何發揮作用。遠程和本地OData服務
{
"_version": "1.1.0",
"sap.app": {
"_version": "1.1.0",
"id": "xxx",
"type": "application",
"title": "{{appTitle}}",
"description": "{{appDescription}}",
"applicationVersion": {
"version": "1.0.0"
},
"dataSources": {
"mainService": {
"uri": "https://services.odata.org/V2/Northwind/Northwind.svc/",
"type": "OData",
"settings": {
"odataVersion": "2.0",
"localUri": "localService/metadata.xml"
}
}
}
},
"sap.ui": {
"_version": "1.1.0",
"technology": "UI5",
"icons": {
"icon": "",
"favIcon": "",
"phone": "",
"[email protected]": "",
"tablet": "",
"[email protected]": ""
},
"deviceTypes": {
"desktop": true,
"tablet": true,
"phone": true
},
"supportedThemes": [
"sap_hcb",
"sap_bluecrystal"
]
},
"sap.ui5": {
"_version": "1.1.0",
"rootView": {
"viewName": "xxx.view.Main",
"type": "XML"
},
"dependencies": {
"minUI5Version": "1.30.0",
"libs": {
"sap.ui.core": {},
"sap.m": {},
"sap.ui.layout": {}
}
},
"contentDensities": {
"compact": true,
"cozy": true
},
"config": {
"productLocal": "localService/mockdata/products.json",
"productRemote": "/some remote end point"
},
"products": {
"dataSource": "mainService"
}
}
}
控制器代碼
var oModel = new sap.ui.model.odata.ODataModel("/", true);
//var data = oModel;
//console.log(data);
var inputModel = new JSONModel("../model/inputs.json");
var productsModel = new JSONModel();
oModel.read("/ProductSet",
null,
null,
false,
function _OnSuccess(oData, response) {
console.log(oData);
console.log(response);
var data = {"ProductCollection" : oData.results};
productsModel.setData(data);
},
function _OnError(error) {
console.log(error);
});
//set model(s) to current xml view
this.getView().setModel(inputModel, "inputModel");
this.getView().setModel(productsModel);
感謝您的幫助。
蘇尼爾,我有我的應用程序兩個入口。一個用於模擬服務器另一個應用程序。我能夠使用Odata模型運行模擬服務器,但是當我嘗試加載index.html時,我得到有關加載路徑的錯誤。我更新我的問題與控制器模擬服務器工作,但未能加載索引,HTML – user557657
'var oModel = new sap.ui.model.odata.ODataModel(「/」,true); var productsModel = new JSONModel(); oModel.read( 「/ ProductSet」, 空, 空, 假, 功能_OnSuccess(ODATA,響應){ VAR數據= { 「ProductCollection」:oData.results}; productsModel.setData(數據); (錯誤){ }, this.getView()。setModel(productsModel);' – user557657
Sunil,在manifest.json中,上面的dataSources屬性uri有一些遠程https端點如果我想在本例中指向本地像「/」,那麼我需要更改清單文件每次? – user557657