Can anybody explain what exactly Aggregation means in SAP UI5 ? I am trying to make an app with two views and i want to navigate from one view to another and vice -versa.
Basic definition of «aggregation» from Glossary:
An aggregation (in the context of UI5) is a special relation between two UI element types. It is used to define the parent-child relationship [...]. The parent end of the aggregation has cardinality 0..1, while the child end may have 0..1 or 0..*.
For example, a list may have 0 or many items. An item has 0 or 1 list as its parent. Therefore, the list has an aggregation of «items».
In our case, the control sap.m.App
, which is extended from sap.m.NavContainer, has a default aggregation named «pages» where we can define a collection of anything extended from sap.ui.core.Control
as its child controls.
pages: sap.ui.core.Control [ ]
But just adding the views manually into
is an anti-pattern since a view has usually a Page in it and a single page takes up 100% of the height which pushes other views away. Besides that, it makes implementing navigation much more difficult.
Instead, the current best practice is to use a so-called «router» which is usually defined in the application descriptor (manifest.json) with other navigation properties. Its sister control Target takes care of adding the navigated view to the «pages» aggregation. To find out how to achieve navigation using a router, take a look at these resources: