我已经配置了信息从SAP UI5访问我的OData服务在manifest.json
{
"sap.app": { ...
},
"dataSources": {
"Test": {
"uri": "/sap/opu/odata/sap/ZHCM_SRV/",
"type": "OData",
"settings": {
"odataVersion": "2.0",
"localUri": "localService/metadata.xml"
}
}
} ...
"sap.ui5": {
"rootView": {
"viewName": "test.view.App",
"type": "XML",
"id": "app"
}, ...
"models": {
"i18n": {
"type": "sap.ui.model.resource.ResourceModel",
"settings": {
"bundleName": "test.i18n.i18n"
}
},
"Test": {
"type": "sap.ui.model.odata.v2.ODataModel",
"settings": {
"defaultOperationMode": "Server",
"defaultBindingMode": "TwoWay",
"defaultCountMode": "None"
},
"dataSource": "Test"
}
},
"routing": { ...
}
在我Component.js我有:
init: function() {
UIComponent.prototype.init.apply(this, arguments);
this.getRouter().initialize();
this.setModel(models.createDeviceModel(), "device");
// I get the Url from configuration in Manifest.json
var sServiceUrl = this.getMetadata().getManifestEntry("sap.app").dataSources["Test"].uri;
// I create the OData
var sabModel = new sap.ui.model.odata.v2.ODataModel(sServiceUrl);
// Load the MetaData.
sabModel.getServiceMetadata();
// Binding to the Model.
this.setModel(sabModel, "Sabbatical");
当我检查oModel我可以看到我已经实例化的模型,但它是空的,没有数据...你有没有过这样的行为? 任何建议???
非常感谢!! CBR