SAPUI5 路由抛出错误“找不到控件(应用程序控件的 ID)”
SAPUI5 routing throws error “Control (ID of an App control) could not be found”
这个问题源自 (I can't get the source code running) , My requirement is similar with ,这是一个带有应用程序控件的页面,导航到具有一个主视图和一个详细视图的 SplitContainer。 Master.view.xml 加载成功,但我得到
"Control with ID app could not be found"
单击项目时出错。
我的metadata.json:
"routing": {
"config": {
"routerClass": "cts.alert.MyRouter",
"viewType": "XML",
"viewPath": "cts.alert.view",
"controlId": "app",
"controlAggregation": "pages",
"clearTarget": "false",
"bypassed": {
"target": [
"notFound"
]
},
"async": true
},
"routes": [
{
"pattern": "",
"name": "worklist",
"target": [
"worklist"
]
},
{
"pattern": "split",
"name": "split",
//<SplitContainer id="idAppControl"> in SplitApp.view.xml
"view": "SplitApp",
//<App id="app"/> in App.view.xml
"targetControl": "app",
"subroutes": [
{
"pattern": "master",
"name": "main",
"view": "Master",
"targetAggregation": "masterPages",
"targetControl": "idAppControl", //SplitContainer id
"subroutes": [
{
"pattern": "VEHICLES/{objectId}",
"name": "object",
"view": "Detail",
"targetAggregation": "detailPages",
}
]
}
]
},
{
"name": "catchallMaster",
"view": "Master",
"targetAggregation": "masterPages",
"targetControl": "idAppControl",
"subroutes": [
{
"pattern": ":all*:",
"name": "catchallDetail",
"view": "NotFound"
}
]
}
],
"targets": {
"master": {
"viewName": "Master",
"viewLevel": 2,
"viewId": "master",
"controlAggregation": "masterPages"
},
"worklist": {
"viewName": "Worklist",
"viewId": "worklist",
"viewLevel": 1
},
"object": {
"viewName": "Detail",
"viewId": "detail",
"viewLevel": 3
},
"objectNotFound": {
"viewName": "ObjectNotFound",
"viewId": "objectNotFound"
},
"notFound": {
"viewName": "NotFound",
"viewId": "notFound"
},
"detailObjectNotFound": {
"viewName": "DetailObjectNotFound",
"viewId": "detailObjectNotFound"
},
"detailNoObjectsAvailable": {
"viewName": "DetailNoObjectsAvailable",
"viewId": "detailNoObjectsAvailable"
}
}
}
我不确定子路径是否还需要那么多目标。我知道问题出在 "targetControl" : "app"
in "split"
route ,但是如果我在 "object"
route 添加 "targetControl" : "idAppControl" ,它也会产生
Control with ID idAppControl could not be found
并且说:
You can't join the same control as your parent route has.
我现在真的很迷茫。
我也试过在 "sap.ui5"
中删除 "rootview"
,但没有用。
欢迎任何帮助!提前致谢!
感谢这个 route configuration doc,我解决了我的问题。
我以为是split
路由中的"targetControl": "app"
导致了这个错误,实际上是因为routing.config
中的"controlId": "app"
导致了这个问题。
The config parameter defines the default values for route configuration.
改完后,又报错了:
The target worklist has no controlId set and no parent so the target cannot be displayed.
所以我删除了 worklist
路由中的 target
并在其中添加了 targetControl: app
,因为它不再具有默认的 targetControl
值。
这里是新的路由配置:
"routing": {
"config": {
"routerClass": "cts.alert.MyRouter",
"viewType": "XML",
"viewPath": "cts.alert.view",
"controlAggregation": "pages",
"clearTarget": "false",
"bypassed": {
"target": [
"notFound"
]
},
"async": true
},
"routes": [
{
"pattern": "",
"name": "worklist",
"view": "Worklist",
"targetControl": "app"
},
{
"pattern": "split",
"name": "split",
"view": "SplitApp",
"targetControl": "app",
"subroutes": [
{
"pattern": "master",
"name": "main",
"view": "Master",
"targetAggregation": "masterPages",
"targetControl": "idAppControl",
"subroutes": [
{
"pattern": "VEHICLES/{objectId}",
"name": "object",
"view": "Detail",
"targetAggregation": "detailPages"
}
]
}
]
},
{
"name": "catchallMaster",
"view": "Master",
"targetAggregation": "masterPages",
"targetControl": "idAppControl",
"subroutes": [
{
"pattern": ":all*:",
"name": "catchallDetail",
"view": "NotFound"
}
]
}
],
}
我会说 manifest.json 中的值 "app" ("controlId": "app"
)
还需要在你的初始视图中匹配应用程序的id
<mvc:View controllerName="MyView" xmlns:core="sap.ui.core" xmlns:mvc="sap.ui.core.mvc"
xmlns="sap.m" xmlns:html="http://www.w3.org/1999/xhtml">
<Shell id="shell">
<App id="app">
这个问题源自
"Control with ID app could not be found"
单击项目时出错。
我的metadata.json:
"routing": {
"config": {
"routerClass": "cts.alert.MyRouter",
"viewType": "XML",
"viewPath": "cts.alert.view",
"controlId": "app",
"controlAggregation": "pages",
"clearTarget": "false",
"bypassed": {
"target": [
"notFound"
]
},
"async": true
},
"routes": [
{
"pattern": "",
"name": "worklist",
"target": [
"worklist"
]
},
{
"pattern": "split",
"name": "split",
//<SplitContainer id="idAppControl"> in SplitApp.view.xml
"view": "SplitApp",
//<App id="app"/> in App.view.xml
"targetControl": "app",
"subroutes": [
{
"pattern": "master",
"name": "main",
"view": "Master",
"targetAggregation": "masterPages",
"targetControl": "idAppControl", //SplitContainer id
"subroutes": [
{
"pattern": "VEHICLES/{objectId}",
"name": "object",
"view": "Detail",
"targetAggregation": "detailPages",
}
]
}
]
},
{
"name": "catchallMaster",
"view": "Master",
"targetAggregation": "masterPages",
"targetControl": "idAppControl",
"subroutes": [
{
"pattern": ":all*:",
"name": "catchallDetail",
"view": "NotFound"
}
]
}
],
"targets": {
"master": {
"viewName": "Master",
"viewLevel": 2,
"viewId": "master",
"controlAggregation": "masterPages"
},
"worklist": {
"viewName": "Worklist",
"viewId": "worklist",
"viewLevel": 1
},
"object": {
"viewName": "Detail",
"viewId": "detail",
"viewLevel": 3
},
"objectNotFound": {
"viewName": "ObjectNotFound",
"viewId": "objectNotFound"
},
"notFound": {
"viewName": "NotFound",
"viewId": "notFound"
},
"detailObjectNotFound": {
"viewName": "DetailObjectNotFound",
"viewId": "detailObjectNotFound"
},
"detailNoObjectsAvailable": {
"viewName": "DetailNoObjectsAvailable",
"viewId": "detailNoObjectsAvailable"
}
}
}
我不确定子路径是否还需要那么多目标。我知道问题出在 "targetControl" : "app"
in "split"
route ,但是如果我在 "object"
route 添加 "targetControl" : "idAppControl" ,它也会产生
Control with ID idAppControl could not be found
并且
You can't join the same control as your parent route has.
我现在真的很迷茫。
我也试过在 "sap.ui5"
中删除 "rootview"
,但没有用。
欢迎任何帮助!提前致谢!
感谢这个 route configuration doc,我解决了我的问题。
我以为是split
路由中的"targetControl": "app"
导致了这个错误,实际上是因为routing.config
中的"controlId": "app"
导致了这个问题。
The config parameter defines the default values for route configuration.
改完后,又报错了:
The target worklist has no controlId set and no parent so the target cannot be displayed.
所以我删除了 worklist
路由中的 target
并在其中添加了 targetControl: app
,因为它不再具有默认的 targetControl
值。
这里是新的路由配置:
"routing": {
"config": {
"routerClass": "cts.alert.MyRouter",
"viewType": "XML",
"viewPath": "cts.alert.view",
"controlAggregation": "pages",
"clearTarget": "false",
"bypassed": {
"target": [
"notFound"
]
},
"async": true
},
"routes": [
{
"pattern": "",
"name": "worklist",
"view": "Worklist",
"targetControl": "app"
},
{
"pattern": "split",
"name": "split",
"view": "SplitApp",
"targetControl": "app",
"subroutes": [
{
"pattern": "master",
"name": "main",
"view": "Master",
"targetAggregation": "masterPages",
"targetControl": "idAppControl",
"subroutes": [
{
"pattern": "VEHICLES/{objectId}",
"name": "object",
"view": "Detail",
"targetAggregation": "detailPages"
}
]
}
]
},
{
"name": "catchallMaster",
"view": "Master",
"targetAggregation": "masterPages",
"targetControl": "idAppControl",
"subroutes": [
{
"pattern": ":all*:",
"name": "catchallDetail",
"view": "NotFound"
}
]
}
],
}
我会说 manifest.json 中的值 "app" ("controlId": "app"
)
还需要在你的初始视图中匹配应用程序的id
<mvc:View controllerName="MyView" xmlns:core="sap.ui.core" xmlns:mvc="sap.ui.core.mvc"
xmlns="sap.m" xmlns:html="http://www.w3.org/1999/xhtml">
<Shell id="shell">
<App id="app">