我有一个业务需求,我正在开发使用基于云的sap webide工具在HCP中部署的sapui5员工离职应用程序。我如何从controller.xml中的sapui5应用程序URL获取值
两种类型的员工将访问使用两个不同的URL与参数的这种应用是“IT”或“外包”:
https://webidetesting453789-inf98834.dispatcher.int.sap.hana.ondemand.com/webapp/index.html#/IT
https://webidetesting453789-inf98834.dispatcher.int.sap.hana.ondemand.com/webapp/index.html#/BPO
后端:我已经开发了是给我的员工详细信息的REST服务当我这样做使用下面的URL无论是IT或BPO如特定员工的GET请求JSON格式:
/irc.com/ircit/empleave/rest/empleave/item/requestor/IT
或
/irc.com/ircit/empleave/rest/empleave/item/requestor/BPO
查看: 我已经使用了一个xml视图MyRequestList,它将以表格形式向我显示来自IT和BPO的所有请求。
要求:
我需要根据在url.For例子传递的参数来获取数据时,在下面的网址,用户点击后,MyRequestView的标题应该是IT员工和IT只请求员工应该出现并且与BPO相同。
https://webidetesting453789-inf98834.dispatcher.int.sap.hana.ondemand.com/webapp/index.html#/IT
问:
如何从应用程序URL参数“IT”或“外包”,并传递给从控制器的看法。 (“MyParam”)没有获取url参数'IT'或'BPO'。我应该使用哪种方法。
RouterConfig:
{
"_version": "1.1.0",
"sap.app": {
"_version": "1.1.0",
"id": "ircit.irc",
"type": "application",
"i18n": "/webapp/i18n/i18n.properties",
"title": "{{appTitle}}",
"description": "{{appDescription}}",
"applicationVersion": {
"version": "1.0.0"
}
},
"sap.ui": {
"_version": "1.1.0",
"technology": "UI5",
"deviceTypes": {
"desktop": true,
"tablet": false,
"phone": false
},
"supportedThemes": [
"sap_bluecrystal"
]
},
"sap.ui5": {
"_version": "1.1.0",
"rootView": "ircit.irc.view.App",
"dependencies": {
"minUI5Version": "1.30",
"libs": {
"sap.m": {}
}
},
"contentDensities": {
"compact": true,
"cozy": true
},
"models": {
"i18n": {
"type": "sap.ui.model.resource.ResourceModel",
"settings": {
"bundleName": "ircit.irc.i18n.i18n"
}
}
},
"resources": {
"css": [
{
"uri": "/webapp/css/style.css"
}
]
},
"routing": {
"config": {
"routerClass": "ircit.generic.utils.CustomRouter",
"viewType": "XML",
"viewPath": "ircit.irc.view",
"controlId": "app",
"fullWidth": true,
"controlAggregation": "pages",
"bypassed": {
"target": [
"notFound"
]
}
},
"routes": [
/*{
"pattern": "",
"name": "myRequests",
"target": "myRequests"
},*/
{
"pattern": "/{id}",
"name": "myRequests",
"target": "myRequests"
},
{
"pattern": "/create",
"name": "create",
"target": "create"
},
{
"pattern": "/create/{id}",
"name": "copy",
"target": "create"
},
{
"pattern": "/id={id}",
"name": "Display",
"target": "display"
}
],
"targets": {
"myRequests": {
"viewName": "MyRequests",
"viewId": "myRequests",
"viewLevel": 1
},
"display": {
"viewName": "Display",
"viewId": "display",
"viewLevel": 2
},
"create": {
"viewName": "Create",
"viewId": "create",
"viewLevel": 2
},
"copy": {
"viewName": "Create",
"viewId": "create",
"viewLevel": 2
},
"notFound": {
"viewName": "NotFound",
"viewId": "notFound"
}
}
}
},
"sap.platform.hcp": {
"uri": "webapp",
"_version": "1.1.0"
}
}
MyRequestController:
onInit: function() {
// set create option (cteate and copy button)
var bValue = jQuery.sap.getUriParameters().get("showCreate");
var oBtn = this.byId("btnCreate");
oBtn.setVisible(bValue !== "false");
var oColumn = this.byId("colCopy");
oColumn.setVisible(bValue !== "false");
this.getRouter().attachRouteMatched(jQuery.proxy(this.onRouteMatched, this));
},
你能否粘贴你的路由器配置?另外,如果你使用基于散列的路由,你可能想看看方法:attachPatternMatched(https://help.sap.com/saphelp_uiaddon20/helpdata/en/23/66345a94f64ec1a80f9d9ce50a59ef/content.htm) –