Using ControlAggregation in SAPUI5


“ControlAggregation” refers to the target aggregation to which the mapped view is added.

As Specified in the use case below:

"routing": {
   "config": {
      "routerClass": "sap.m.routing.Router",
      "viewType": "XML",
      "viewPath": "sap.ui.demo.nav.view",
      "controlId": "app",
      "controlAggregation": "dummy",
      "transition": "slide",
      "bypassed": {
         "target": "NA"
      }

Example

The views are defined as follows:

<mvc:View
   controllerName="sap.ui.demo.nav.controller.App"
   xmlns="sap.m"
   xmlns:mvc="sap.ui.core.mvc"
   displayBlock="true">
   <App id="sampleApp"/>
</mvc:View>

So here “controlAggregation” is named as 'dummy' but the app is named as SampleApp.

so the target is 'sap.m.SampleApp' and aggregation is named as 'dummy'. Let us take an example here:

routes :[{ pattern:"employee/{id}",
   name:"employee",
   target:"employee"
},
{
   pattern:"department/{id}",
   name :"department",
   target:"department"
}],
targets:{
   employee:{
      viewName:"Employee",
      controlAggregation:"masterPage"
   },
   department"{
      viewName:"Department",
      controlAggregation:"contentPage"
   }
}

So when a user navigates to employee/3, routing engine finds that 'Employee' is the target for this pattern. Then it tries to find the name of the view for that target i.e. 'Employee'. After this, it will determine the control aggregation for this View if any. Here we have it to be “masterPage”. Now the View Engine will render the view inside the “masterPage”.

Updated on: 16-Dec-2019

455 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements