SAPUI5路由配置中'controlAggregation'的含义是什么?

编程入门 行业动态 更新时间:2024-10-08 12:32:04
本文介绍了SAPUI5路由配置中'controlAggregation'的含义是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

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

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

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

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

  • viewName:Category ,
  • controlId(视图的容器):splitApp
  • 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:

  • viewName : Category ,
  • controlId(the container of view) : splitApp
  • 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'的含义是什么?

    本文发布于:2023-11-22 08:08:52,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/1616619.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:路由   含义   controlAggregation

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!