0 votes
1 view
in SAP by (7k points)

This question derived from this answer (I can't get the source code running) , My requirement is similar with this question, which is a page with app control, navigate to a SplitContainer with one master and one detail view. Master.view.xml is loaded successfully, But I get
"Control with ID app could not be found"
error when I click item.
my 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"
    }
  }
}

I am not sure if subroutes still need so many targets. And I know the problem lies in "targetControl" : "app" in "split" route , but if I add "targetControl" : "idAppControl" in "object" route , it will also produce
Control with ID idAppControl could not be found
And this answer said:
You can't join the same control as your parent route has.
I am really confused now .
And I also tried delete "rootview" in "sap.ui5" , not working.
Any help will be welcomed! Thanks in advance!

1 Answer

0 votes
by (14.5k points)

The "controlId": "app" in routing.config is actually causing this problem. The config parameter defines the default values for route configuration.

After changing that, I got another error: 

The target worklist has no controlId set and no parent so the target cannot be displayed.

So I deleted target in the worklist route and added targetControl: app in it as it no longer contains a default targetControl value.

Here is the new route configuration:

"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"

                }

            ]

        }

    ],

}

Related questions

Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...