0

I am creating an app using Navigation and Routing concept and was unable to understand the metadata which needs to be specified in Component.js

What is the meaning of below :-

"controlId": "app",
"controlAggregation": "pages",

When I am checking the documentation Component.js it is mentioned as -

targetParent: "myViewId",
targetControl: "app",
targetAggregation: "pages",

Can someone explain the difference between the above two and it will be helpful what exactly it means?

Rahul
  • 143
  • 2
  • 16

2 Answers2

2

With below XML view code as an example, I will elaborate about the metadata configuration.

<core:View xmlns:core="sap.ui.core" xmlns="sap.m" controllerName="Demo.view.Main" displayBlock="true" height="100%">
    <App id="app">
    </App>
</core:View>

App control is the root element for UI5 mobile application. It has pages aggregation as it extends from NavContainer.

targetControl: "app",
targetAggregation: "pages"

targetControl is specified with ID of control which is used to display the pages. In above XML, App control has "app" as it's ID. So, all your views will be placed in pages aggregation of App control.

Now, you might be wondering how views can be placed in pages aggregation. If you look at type of controls allowed in pages aggregation is Control. Any control which extends Control class can be placed in pages of App. As View is also Control it is valid to be added in pages aggregation.

So, all views in application are placed in App.

"targetParent": "myViewId"

targetParent is nothing but the view in which App control is placed.

Regarding difference between above and this

"controlId": "app",
"controlAggregation": "pages"

In newer version of SAPUI5, we specify configuration in manifest.json file instead of Component.js file. So, you will find this configuration their. They are one and same but only with different names.

Ashish Patil
  • 1,624
  • 2
  • 11
  • 27
0

Following are the Configuration Parameters for Navigation

  • routes :- The routes parameter defines an array of route configurations.
  • config :- The config parameter defines the default values for route configuration.
  • view :- The view parameter contains the name of the view that is created on the first time a route is matched. To place the view in a control, use targetAggregation and targetControl. Views are only created once.
  • targetParent :- The target parent parameter defines the ID of the parent of the targetControl parameter.
  • targetControl :- Views are put into a container control, for example a shell control or a NavContainer for mobile applications, or into any other container. The targetControl parameter contains the ID of this control.
  • targetAggregation :- The target application parameter contains the name of an aggregation of the target control that contains views. A NavContainer, for example, has an aggregation called Pages and the shell container has Content.
  • subroutes :- The subroutes parameter contains an array of routes and can contain the complete route configuration. Routes that are added to subroutes may have subroutes themselves.
  • callback :- The callback parameter is an optional function that is executed after the route has matched.
Mahendra Kulkarni
  • 1,437
  • 2
  • 26
  • 35