当前位置:网站首页>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");边栏推荐
猜你喜欢
随机推荐
JS: 数组和树的相互转换
awk statistical difference record
红外图像滤波
动手学深度学习_VggNet
Zip4j使用
Finger Vein Recognition-matlab
程序员如何在职场上少走弯路?
Seata source code analysis: various message processing processes of seata server
awk 统计平均 最大 最小值
zynq 记录
Spark提交参数说明和常见优化
win10 uwp xaml 绑定接口
NLP技术为何在工业界这么卷?前沿案例解析来了
The list of Kubernetes - watch mechanism
Kubernetes之list-watch机制
用“绿色计算“技术推动算力可持续发展
SAP UI5 确保控件 id 全局唯一的实现方法
awk 统计差值记录
《学会写作》粥佐罗著
02 ts 变量定义,类型









