Reputation: 9
I am trying to load the Northwind V4 oData Service into my view. I use the tutorial at https://openui5beta.hana.ondemand.com/#docs/guide/44062441f3bd4c67a4f665ae362d1109.html but it doesn't even work there. I declared the model in my manifest.json file and want to display the information in a basic table. How should I do this? I tried to set the model in the controller, but it didnt work.
This is my manifest.json. You see, I have declared the model according to the developers guide
{
"_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"
}
]
}
}
}
This is my xml file, where I want to set the model and display the entries.
<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>
Here is my neo-app.json code
{
"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
}
Upvotes: 0
Views: 3756
Reputation: 11
Try this:
"dataSources": {
"invoiceRemote": {
"uri": "/northwind/V2/Northwind/Northwind.svc/",
"type": "OData",
"settings": {
"localUri": "localService/metadata.xml",
"odataVersion": "2.0"
}
}
}
In neo-app.json route:
{
"path": "/northwind",
"target": {
"type": "destination",
"name": "northwind"
},
}
Documentation: Create a Northwind Destination
Upvotes: 1
Reputation: 5206
The problem is that the URI that you specified in the data source points towards the categories collection (the Categories
segment at the end of the URI). The OData model URI must point towards the service root path: /destinations/northwind/V4/Northwind/Northwind.svc/
.
Also, you are binding your table against the /value
path. This implies that you expect having an value
collection. I guess you wanted to bind against the categories collection, so you should change that to <Table items="{/Categories}">
.
Upvotes: 0