声明式支持问题 [英] Declarative support questions

查看:30
本文介绍了声明式支持问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将 htmlview(根据 SAP 的文档使用声明性支持)添加到也使用声明性支持的索引页面.使用 data-sap-ui-type="ui.MyView" 让我问两个问题:

  • 在声明性支持方面是否有与 sap.ui.localResources 等效的东西?
  • data-ui-type 没有将 view.html 后缀添加到应该加载的视图中.MVC 是否有声明式支持的特殊模式,或者目前没有办法实现它?

亲切的问候,妮可

解决方案

在这里找到一些基本示例:https://openui5.hana.ondemand.com/#docs/guide/MVC.html

首先我相信你总是需要在代码中设置sap.ui.localResources.

正如你所看到的,从 HTMLView 实例化一个 HTMLView 是这样的:

<div data-sap-ui-type="sap.ui.core.mvc.HTMLView" id="MyHTMLView" data-view-name="example.mvc.test2"></div>

这将加载 example.mvc.test2.view.html 并将其放入您的父视图中.

一般来说,JS API 转换成 HTMLViews 是这样的:

new sap.ui.AnyControl("myId", {aLittleProperty: "10",属性:假,按:functionInMyController,morePress: a.static.myFunction,默认聚合:[新 sap.ui.OtherControl("otherId1"),新 sap.ui.OtherControl("otherId2")],anotherAggregation: new sap.ui.OtherControl("otherId3")}).addStyleClass("myClass");<div data-sap-ui-type="sap.ui.AnyControl"身份证=我的身份证"班级=我的班级"data-a-little-property="10",数据属性=假"数据新闻=functionInMyController"data-more-press="a.static.myFunction"><div data-sap-ui-type="sap.ui.OtherControl" id="otherId1"></div><div data-sap-ui-type="sap.ui.OtherControl" id="otherId2"></div><div data-sap-ui-aggregation="anotherAggregation"><div data-sap-ui-type="sap.ui.OtherControl" id="otherId3"></div>

注意:

  • id 和 CSS 类使用常规 HTML 属性设置
  • 属性名称从驼峰式转换为小写,以-"分隔(因为 HTML 不区分大小写)
  • 无论属性是什么类型,您当然都必须在 HTML 中将其放在引号中
  • 直接放入 HTML 定义的控件中的任何内容都被视为属于它的默认聚合

BR克里斯

I am trying to add an htmlview (which is using declarative support according to SAP's docs) to an index page that is also using declarative support. Using data-sap-ui-type="ui.MyView" makes me to ask two questions:

  • Is there any equivalent to sap.ui.localResources in declarative support?
  • data-ui-type is not adding the view.html suffix to the view that should be laoded. Is there a special pattern for MVC in declarative support or is there currently no way to implement it?

Kind regards, Nico

解决方案

find some basic samples here: https://openui5.hana.ondemand.com/#docs/guide/MVC.html

First of all I believe that you always have to set sap.ui.localResources in code.

As you can see instanciating a HTMLView from an HTMLView goes like this:

<div data-sap-ui-type="sap.ui.core.mvc.HTMLView" id="MyHTMLView" data-view-name="example.mvc.test2"></div>

This will load example.mvc.test2.view.html and place it into your parent view.

Generally speaking the JS API translates into HTMLViews like this:

new sap.ui.AnyControl("myId", {
  aLittleProperty: "10",
  property: false,

  press: functionInMyController,
  morePress: a.static.myFunction,

  defaultAggregation: [ 
     new sap.ui.OtherControl("otherId1"),
     new sap.ui.OtherControl("otherId2")
  ],
  anotherAggregation: new sap.ui.OtherControl("otherId3")
}).addStyleClass("myClass");

<div data-sap-ui-type="sap.ui.AnyControl" 
     id="myId" 
     class="myClass"

     data-a-little-property="10",
     data-property="false"

     data-press="functionInMyController"
     data-more-press="a.static.myFunction">

     <div data-sap-ui-type="sap.ui.OtherControl" id="otherId1"></div>
     <div data-sap-ui-type="sap.ui.OtherControl" id="otherId2"></div>

     <div data-sap-ui-aggregation="anotherAggregation">
         <div data-sap-ui-type="sap.ui.OtherControl" id="otherId3"></div>
     </div>

</div>

Note that:

  • The id and CSS classes are set with the regular HTML attributes
  • Property names translate from camelCase to lower-case separated with "-" (due to the fact that HTML is not case-sensitive)
  • No matter what type the property is you of course have to put it in quotes in HTML
  • Whatever you put directly inside a HTML-defined control is considered to belong into it's default aggregation

BR Chris

这篇关于声明式支持问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
其他开发最新文章
热门教程
热门工具
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆