当前位置:网站首页>SAP UI5 ensures that the control id is globally unique implementation method
SAP UI5 ensures that the control id is globally unique implementation method
2022-08-04 19:33:00 【HUAWEI CLOUD】
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");
边栏推荐
猜你喜欢
随机推荐
VQ Realization of Wavelet Extraction Features
TikTok如何为独立站引流?
MYSQL获取数据库的表名和表注释
Internship: changed the requirements
WPF 元素裁剪 Clip 属性
T+Cloud: A "Smart Company" for Building New Business Social Networks and Marketing Relationships
Dragoma (DMA) Metaverse System Development
指静脉识别-matlab
WPF 使用封装的 SharpDx 控件
小波提取特征的VQ实现
win10 uwp xaml 绑定接口
如何搭建 RADIUS 云服务器?
visual studio 与 visual studio code
Openharmony first experience (1)
拥抱Cmake小朋友 简单又实用,但是不灵活
Orthodontic MIA micro-implant anchorage technology China 10th anniversary exchange meeting was held in Shenyang
【最新资讯】2022下半年软考新增2个地区公布报名时间
Video Object Detection
宏定义小方法
Chrome 开发者工具 performance 标签页的用法