SAP WebIDE一个和Destination相关的问题 - OData下拉菜单里的Destination从哪里来的
我今天做开发遇到一个问题:
我有trial和正式的SAP Cloud Platform账号各一个:
其中trial账号的webIDE连接到productive的CloudFoundry:

productive账号的WebIDE也连接到productive的CloudFoundry:

我发现在我新建OData服务时,从Service url的下拉菜单里,选择不到我在SAP云平台里创建的Destination.

 
怎么感觉trial WebIDE取的Destination来自trial neo环境创建的?

而productive的WebIDE,system下拉菜单里的Destination也来自productive Neo环境的Destination.

似乎CloudFoundry环境的Destination根本没有被考虑。
再检查我使用的webIDE的url.
trial:
https://webidecp-i042416trial.dispatcher.hanatrial.ondemand.com/

后来发现了一个github issue:
 https://github.com/SAPDocuments/Tutorials/issues/3398
 得知如果在SAP WebIDE里创建UI5应用,需要用Destination连结第三方服务时,需要在Neo环境里创建Destination,而不是在CloudFoundry环境里。
为了验证,我再次在Neo环境里创建一个Destination:

 
然后果然在WebIDE里看到了这个创建于Neo环境的Destination.
WebIDE Preferences里维护的CloudFoundry endpoint只是开发好的UI5应用部署的目的地。

那么问题又来了,既然这个UI5应用最终部署在SAP云平台的CloudFoundry环境下,如果CloudFoundry环境没有对应的Destination,运行时的表现是怎样的?
经过我实际测试,发现取不到OData服务的metadata,报500 Internal Server Error的错误。

于是我把Neo环境里创建的Destination导出,再倒入到CloudFoundry环境,这次发现OData metadata终于能够成功返回了:

在XML view里,使用List标签引入列表:

<mvc:View controllerName="sapcp.cf.tutorial.app.controller.View1" xmlns:mvc="sap.ui.core.mvc" displayBlock="true" xmlns="sap.m">
	<Shell id="shell">
		<App id="app">
			<pages>
				<Page id="page" title="{i18n>title}">
					<content>
						<List items="{/Products}">
							<StandardListItem type="Active" press="handleListItemPress" title="{ProductName}"/>
						</List>
					</content>
				</Page>
			</pages>
		</App>
	</Shell>
</mvc:View>
上面代码里注册的列表元素点击处理函数handleListItemPress,实现在控制器文件里:

sap.ui.define([
	"sap/ui/core/mvc/Controller",
	"sap/m/MessageBox"
], function (Controller, MessageBox) {
	"use strict";
	return Controller.extend("sapcp.cf.tutorial.app.controller.View1", {
		onInit: function () {
		},
		// show in a pop-up which list element was pressed
		handleListItemPress: function (oEvent) {
			MessageBox.show(
				"You pressed item: " + oEvent.getSource().getBindingContext(), {
					icon: sap.m.MessageBox.Icon.INFORMATION,
					title: "It works!",
					actions: [sap.m.MessageBox.Action.OK]
				}
			);
		}
	});
});
运行效果:点击列表元素:

弹出对话框:

- 点赞
- 收藏
- 关注作者
 
             
           
评论(0)