如何在不返回视图组件的情况下启动XML预处理器

时间:2016-09-02 14:10:51

标签: sapui5

我正在尝试为我们在这里使用的一组应用程序创建一个启动板。我的一个问题是我需要在tile容器中添加不同的tile(幻灯片,自定义,标准等),我认为这可能是一个解决方案是使用XML模板来做到这一点。我想要实现的是:

<TileContainer id="tileList"
                allowAdd="true"
                tileDelete="onDelete"
                tiles="{path:'Atalhos>/' ,sorter:{path:'Atalhos>TileText',group:false}}">
                <template:if test="{path:'Atalhos>TileCode', operator:'EQ',value1:'teste1'}">
                    <template:then>
                        <core:Fragment fragmentName="pelissari.soficom.launchpad.view.StandardTile" type="XML"/>
                    </template:then>
                    <template:else>
                        <core:Fragment fragmentName="pelissari.soficom.launchpad.view.StandardTile" type="XML"/>
                    </template:else>                    
                </template:if>
            </TileContainer>

但问题是,当我尝试这样做时,我遇到了这个错误。

  

UIComponent-dbg.js:52未捕获错误:无法加载   'http://schemas/sap/com/sapui5/extension/sap/ui/core/template/1/if.js'   从   资源/ http://schemas/sap/com/sapui5/extension/sap/ui/core/template/1/if.js:   404 - 未找到

我知道我需要启动预处理器来使用预处理指令,但是我发现的所有示例都让我比以前更加困惑。

我的项目基于sapui5教程“WalkThrough,其中我有一个组件,用于启动清单中配置的应用程序视图,此视图通过在mainfest中再次路由配置导航到启动板视图。所有示例都创建一个视图在组件CreateComponent函数中或在一些加载其他视图的控制器函数中。我只需要启动预处理器以获取从实体集“/ TileSet”加载的tile列表。

1 个答案:

答案 0 :(得分:1)

我找到了另一种方法来做我想做的事。现在我正在使用工厂功能来创建我需要的瓷砖。

tileFactory: function(sId, oContext) {
  var atalho = oContext.getProperty(oContext.sPath)
  var oUIControl = null;
  if (atalho.TileCode == 'teste2') {
    oUIControl = new sap.m.StandardTile(sId, {
      title: atalho.TileText
    });
    oUIControl.addStyleClass('tileSize3');
  } else {
    oUIControl = new sap.m.StandardTile(sId, {
      title: atalho.TileText
    });
    oUIControl.addStyleClass('tileSize1');
  }
  oUIControl.attachPress(this.onPress, this);
  oUIControl.addStyleClass('tile');

  return oUIControl;
}
<Page id="tileGroup" showHeader="true"
		content="{path:'Atalhos>/' ,sorter:{path:'Atalhos>TileOrder',group:false},factory:'.tileFactory'}">