2016-08-26 33 views
1

此問題來自this answer(我無法獲得源代碼的運行),我的要求與this question類似,它是應用程序控制,使用一個主控和一個詳細視圖導航到SplitContainer。 Master.view.xml成功加載,但我得到SAPUI5路由拋出錯誤「無法找到控件(應用程序控件的ID)」

"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""split"路線,但如果我添加 「targetControl」:在"object"路線 「idAppControl」,它也將產生

Control with ID idAppControl could not be found

this answer說:

You can't join the same control as your parent route has.

我我現在真的很困惑。

而且我也試過刪除"rootview""sap.ui5",不工作。

任何幫助將受到歡迎!提前致謝!

回答

0

感謝這route configuration doc,我解決了我的問題。

我以爲是"targetControl": "app"split路由導致這個錯誤,但實際上是因爲"controlId": "app"routing.config導致這個問題。

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" 
       } 
      ] 
     } 
    ], 
} 
相關問題