Aggregation in SAP UI5

前端 未结 2 1133
礼貌的吻别
礼貌的吻别 2021-01-16 10:46

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.

2条回答
  •  臣服心动
    2021-01-16 10:52

    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:

    • Examples: Basic navigation, navigation inside a static parent control
    • «Routing and Navigation» from Walkthrough (see also further steps)
    • «Routing and Navigation» from Essentials to understand the basic concepts.

提交回复
热议问题