【问题标题】:Show SAPUI5 View two times simultaneous同时显示两次 SAPUI5 查看
【发布时间】:2019-06-12 11:19:00
【问题描述】:

我构建了一个 sapui5 应用程序,它显示与 SAP 工厂相关的信息。现在我需要在同一页面上显示相同的视图两次,但要显示两种不同植物的信息。想象一下两个 iFrame。该应用程序应该能够仅使用一个视图运行(就像现在一样),并且它应该能够在同一页面上多次显示数据。

为了解决这个问题,我构建了一个额外的视图(splitview),其中包含一个组件容器来加载“真实”视图(主视图)。这以一个连续的循环结束。

这就是我尝试构建拆分视图的方式

<mvc:View xmlns:core="sap.ui.core" xmlns:mvc="sap.ui.core.mvc" xmlns="sap.m" xmlns:l="sap.ui.layout"
    controllerName="zqinsplotlist.zqinsplotlist.controller.splitview" xmlns:html="http://www.w3.org/1999/xhtml">
    <App>
        <pages>
            <Page title="Title">
                <content>
                    <l:HorizontalLayout class="sapUiContentPadding">
                        <ComponentContainer xmlns="sap.ui.core" name="zqinsplotlist.zqinsplotlist"
                            settings='\{ "componentData" : \{ "startupParameters" : \{"Werks" : ["1001"], "Zfcod" : ["PLOS"], "Herkunft" : ["03"] \} \}\}'/>
                        <Text text="Hello Split"/>
                    </l:HorizontalLayout>
                </content>
            </Page>
        </pages>
    </App>
</mvc:View>

我预计这将加载我的主视图一次。但它会一遍又一遍地循环调用。

【问题讨论】:

  • 看起来你正在加载组件zqinsplotlist.zqinsplotlist它本身name="zqinsplotlist.zqinsplotlist",这可能吗?这会导致无限循环

标签: sapui5


【解决方案1】:

你为什么不尝试一下。像这样:

<mvc:View 
  xmlns:core="sap.ui.core" 
  xmlns:mvc="sap.ui.core.mvc" 
  xmlns="sap.m" 
  xmlns:l="sap.ui.layout"
  controllerName="zqinsplotlist.zqinsplotlist.controller.splitview" 
  xmlns:data="http://schemas.sap.com/sapui5/extension/sap.ui.core.CustomData/1"
  xmlns:html="http://www.w3.org/1999/xhtml">
  <App>
    <l:HorizontalLayout class="sapUiContentPadding">
      <mvc:XMLView 
        viewName="zqinsplotlist.zqinsplotlist.view.MyView" 
        data:some="data to distinguish the views" 
        data:instance="1"
      />
      <mvc:XMLView
        viewName="zqinsplotlist.zqinsplotlist.view.MyView" 
        data:some="other data to distinguish this view from the above" 
      />              
    </l:HorizontalLayout>
  </App>
</mvc:View>

在 MyView 的控制器中通过 sth 区分两个视图实例。像这样:

if (this.getView().data('instance') === 1) {
  // do stuff
}

应该可以,但我还没有测试过。不能 100% 确定自定义数据适用于从 XML 实例化的视图。嗯,应该...

BR 克里斯

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-09-03
    • 1970-01-01
    • 2013-10-03
    • 1970-01-01
    相关资源
    最近更新 更多