我有一個業務需求,我正在開發使用基於雲的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) –