当前位置:网站首页>SAP UI5 确保控件 id 全局唯一的实现方法
SAP UI5 确保控件 id 全局唯一的实现方法
2022-08-04 19:31:00 【华为云】
stable ID 用于在运行时识别和修改控制器内的控件。 但是,如果您重用或嵌套这些视图,这些 stable ID 将不再是唯一的。 为了避免 id 冲突,每个 SAP UI5 视图都将自己的 ID 作为前缀添加到其所有子控件中。
看一个例子,下面这个 xml 视图里,Button 控件的 id 为:aButton
<mvc:View viewName="sap.hcm.ButtonView" controllerName="sap.hcm.myController" xmlns="sap.m" xmlns:mvc="sap.ui.core.mvc"> <Button id="aButton" text="Click me"/><mvc:View>然后我定义了另一个 xml 视图,把上面这个包含了 button 控件的 xml 视图,嵌套进去:
<mvc:View viewName="sap.hcm.ContainerView" controllerName="sap.hcm.Address" xmlns="sap.ui.commons" xmlns:core="sap.ui.core" xmlns:html="http://www.w3.org/1999/xhtml"> <mvc:View id="ButtonView1" viewName="sap.hcm.ButtonView"/> <mvc:View id="ButtonView2" viewName="sap.hcm.ButtonView"/><mvc:View>运行时,两个被嵌套的 xml 视图 id 为:
myContainerView–ButtonView1
myContainerView–ButtonView2
获取这些嵌入 xml 视图实例的代码:
var oButtonView1 = oView.byId("ButtonView1");获取每个 xml 视图实例里的 button 实例的代码:
var oButton = oButtonView1.byId("aButton");边栏推荐
- 判断字符串中是否包含中文
- 正则表达式未完
- openharmony初体验(1)
- 【Attention 演变史】RNN的产生、架构、推广、问题(第一弹)
- Highlights of some performance tests
- [Latest Information] 2 new regions will announce the registration time for the soft exam in the second half of 2022
- 对比几类主流的跨端技术方案
- ros2订阅esp32发布的电池电压数据
- 【最新资讯】2022下半年软考新增2个地区公布报名时间
- 如何理解 SAP UI5 的 sap.ui.define 函数
猜你喜欢
随机推荐
In July 2022, domestic database memorabilia
Orthodontic MIA micro-implant anchorage technology China 10th anniversary exchange meeting was held in Shenyang
拥抱Cmake小朋友 简单又实用,但是不灵活
Exploration and Practice of Database Governance
直播回顾|7 月 Pulsar 中文开发者与用户组会议
企业应当实施的5个云安全管理策略
Yuanguo chain game system development
[Sql brush topic] Query information data--Day1
How to monitor code cyclomatic complexity by refactoring indicators
Query the published version records of the APP Store
win10 uwp MetroLog 入门
【Attention演变史】翻译模型seq2seq (第二弹)
win10 uwp win2d 离屏渲染
SAP UI5 视图控制器 View Controller 的生命周期方法 - Lifecycle methods
如何进行自动化测试?【Eolink分享】
华为WLAN技术:AP上线及相关模板的配置实验
网络运维管理从基础到实战-自用笔记(1)构建综合园区网、接入互联网
JS手写JSON.stringify() (面试)
MMDetection 使用示例:从入门到出门
HCIA-R&S自用笔记(22)STP状态与计时器、STP拓扑变化、STP配置及实验
![[Sql刷题篇] 查询信息数据--Day1](/img/a7/67b59bd41803dfc07ecb8f00669c29.png)







