SAPUI5路由配置中'controlAggregation'的含义是什么? [英] What is the meaning of 'controlAggregation' in the SAPUI5 routing configuration?

查看:293
本文介绍了SAPUI5路由配置中'controlAggregation'的含义是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我真的不知道下面的属性controlAggregation用于路由SAPUI5应用程序。
没有带有该ID的元素。我无法在此处的演示应用程序中的任何位置找到对页面的任何引用:



所以当你导航到 category / {id} ,sapui5找出路由中该模式的目标是什么。这是类别



接着它找到 viewName 对于此目标(此处为类别),在目标对象内(请参阅routes数组后面有一个包含catagory,products ...的目标对象)。
所以SapUI5得到了渲染的视图。但是在哪里渲染这个视图?



答案是 - 它将找到为该viewName提到的controlAggregation(内部类别)。在这个例子中,它被称为 masterPages 。现在它将在 config 中找到 controlId 。它是 splitApp 。所以最后它了解了所有必需的信息。即:


  1. viewName:Category

  2. controlId(视图的容器):splitApp

  3. controlAggregation:masterPage

现在sapui5将在类别视图> masterPage splitApp 的汇总。



但注意---- ** In你的情况如果 targets 对象中没有提到controlAggegation,则在 config 中提到它。这意味着对于所有视图都有一个共同的controlAggregation即页面。



所以在这种情况下,sapui5将在页面内呈现你的视图 app 的汇总。



我想你现在了解这个流程。


I really don't get what the property controlAggregation below does for routing a SAPUI5 application. There is not element with that id. I cant find any reference to 'pages' anywhere in the demo app found here: SAPUI5 routing demo

"routing": {
        "config": {
            "routerClass": "sap.m.routing.Router",
            "viewType": "XML",
            "viewPath": "sap.ui.demo.nav.view",
            "controlId": "app",
            "controlAggregation": "pages",   // what does this do?
            "transition": "slide",
            "bypassed": {
                "target": "notFound"
            }

The views are defined as below- no mention of 'pages'

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

And

<mvc:View
    controllerName="sap.ui.demo.nav.controller.Home"
    xmlns="sap.m"
    xmlns:mvc="sap.ui.core.mvc">
    <Page title="{i18n>homePageTitle}" class="sapUiResponsiveContentPadding">
        <content>
            <Button id="displayNotFoundBtn" text="{i18n>DisplayNotFound}" press="onDisplayNotFound" class="sapUiTinyMarginEnd"/>
        </content>
    </Page>
</mvc:View>

解决方案

controlAggregation is the target aggregation to which the view is added.

like in this case target is an sap.m.App whose id is app.

app has an aggregation named as pages.

For detail see routing configuration.

UPDATED IN DETAIL:

Assume controlId is the your container for pages and the container's content is going to be changed for each different routes.

Here container's content is nothing but the pages aggregation of app.

While we use routing, you just need a configuration of the routes and there targets. Let's take one example

So when you navigateTo category/{id}, sapui5 finds out what is the target for that pattern in the routes. Here it is category.

Next it finds the viewName for this target(Here it is category) inside the targets object(see after routes array there is a targets object containing catagory,products...). So SapUI5 got the view to render. But where to render this view?

The answer is - it will find the controlAggregation (inside category) mentioned for that viewName. In this example, it is there called masterPages. now it will find what is the controlId in the config. It is splitApp. So Finally it got to know all the required information. i.e:

  1. viewName : Category ,
  2. controlId(the container of view) : splitApp
  3. controlAggregation : masterPage

Now sapui5 will render Category view inside the masterPage aggregation of splitApp.

But Note ----** In your case if controlAggegation is not mentioned in the targets object, It is mentioned in the config. That means for all the views there is a common controlAggregation that is pages.

So In this case sapui5 will render your views inside the pages aggregation of app.

I think you understand the flow now.

这篇关于SAPUI5路由配置中'controlAggregation'的含义是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆