我正在尝试将Northwind V4 oData服务加载到我的视图中。我在https://openui5beta.hana.ondemand.com/#docs/guide/44062441f3bd4c67a4f665ae362d1109.html使用了教程,但它甚至没有在那里工作。 我在manifest.json文件中声明了模型,并希望在基本表中显示信息。我该怎么做?我试图在控制器中设置模型,但它没有用。
这是我的manifest.json。你看,我已经根据开发者指南声明了模型
{
"_version": "1.1.0",
"sap.app": {
"_version": "1.1.0",
"id": "sap.ui.demo.wt",
"type": "application",
"i18n": "i18n/i18n.properties",
"title": "{{appTitle}}",
"description": "{{appDescription}}",
"applicationVersion": {
"version": "1.0.0"
},
"dataSources": {
"invoiceRemote": {
"uri": "/destinations/northwind/V4/Northwind/Northwind.svc/Categories",
"type": "OData",
"settings": {
"odataVersion": "2.0"
}
}
}
},
"sap.ui": {
"_version": "1.1.0",
"technology": "UI5",
"deviceTypes": {
"desktop": true,
"tablet": true,
"phone": true
},
"supportedThemes": [
"sap_hcb",
"sap_belize"
]
},
"sap.ui5": {
"_version": "1.1.0",
"rootView": "sap.ui.demo.wt.view.App",
"dependencies": {
"minUI5Version": "1.30",
"libs": {
"sap.m": {}
}
},
"models": {
"i18n": {
"type": "sap.ui.model.resource.ResourceModel",
"settings": {
"bundleName": "sap.ui.demo.wt.i18n.i18n"
}
},
"invoice": {
"dataSource": "invoiceRemote"
}
},
"resources": {
"css": [
{
"uri": "css/style.css"
}
]
}
}
}
这是我的xml文件,我想设置模型并显示条目。
<mvc:View controllerName="oDataTest2.controller.main" xmlns:html="http://www.w3.org/1999/xhtml" xmlns:mvc="sap.ui.core.mvc"
displayBlock="true" xmlns="sap.m" xmlns:com="sap.ui.commons">
<App>
<pages>
<Page title="{i18n>title}">
<content>
<Table items="{/value}">
<headerToolbar>
<Toolbar>
<Title text="Categories" level="H2" />
</Toolbar>
</headerToolbar>
<columns>
<Column>
<Text text ="Category ID" />
</Column>
<Column>
<Text text="Category Name" />
</Column>
<Column>
<Text text="Description" />
</Column>
</columns>
<items>
<ColumnListItem>
<cells>
<Text text="{CategoryID}"/>
<Text text="{CategoryName}"/>
<Text text="{Description}"/>
</cells>
</ColumnListItem>
</items>
</Table>
</content>
</Page>
</pages>
</App>
</mvc:View>
这是我的neo-app.json代码
{
"welcomeFile": "/webapp/index.html",
"routes": [
{
"path": "/resources",
"target": {
"type": "service",
"name": "sapui5",
"entryPath": "/resources",
"version": "1.44.10"
},
"description": "SAPUI5 Resources"
},
{
"path": "/test-resources",
"target": {
"type": "service",
"name": "sapui5",
"entryPath": "/test-resources",
"version": "1.44.10"
},
"description": "SAPUI5 Test Resources"
},
{
"path": "/destinations/northwind",
"target": {
"type": "destination",
"name": "northwind"
},
"description": "Northwind OData Service"
}
],
"sendWelcomeFileRedirect": true
}
答案 0 :(得分:0)
问题是您在数据源中指定的URI指向类别集合(URI末尾的Categories
段)。 OData模型URI必须指向服务根路径:/destinations/northwind/V4/Northwind/Northwind.svc/
。
此外,您将表格绑定到/value
路径。这意味着您希望拥有value
集合。我想你想要绑定类别集合,所以你应该将其更改为<Table items="{/Categories}">
。
答案 1 :(得分:0)
试试这个:
"dataSources": {
"invoiceRemote": {
"uri": "/northwind/V2/Northwind/Northwind.svc/",
"type": "OData",
"settings": {
"localUri": "localService/metadata.xml"
}
}
}
{
"path": "/northwind",
"target": {
"type": "destination",
"name": "northwind"
},