SAP UI5 walkthrough step5 Controllers

在这个章节,我们要做的是,将之前的text文本展示为一个按钮,并将声明绑定在点击按钮事件。

因为改的是外观,所以我们修改的是view.XML

webapp/view/App.view.xml

复制代码
<mvc:View
   controllerName="ui5.walkthrough.controller.App"
   xmlns="sap.m"
   xmlns:mvc="sap.ui.core.mvc">
   <Button
      text="Say Hello"
      press=".onShowHello"/>
</mvc:View>

根据MVC架构原理,这种点击按钮事件,应该放在controller里面

所以我们这边要新建一个App.controller.js

webapp/controller/App.controller.js (New)

复制代码
sap.ui.define([
   "sap/ui/core/mvc/Controller"
], (Controller) => {
   "use strict";

   return Controller.extend("ui5.walkthrough.controller.App", {
      onShowHello() {
         // show a native JavaScript alert
         alert("Hello World");
      }
   });
});

Conventions

  • Controller names are capitalized

  • Controllers carry the same name as the related view (if there is a 1:1 relationship)

  • Event handlers are prefixed with on

  • Controller names always end with *.controller.js

最后输出的效果如下

相关推荐
duangww7 天前
SAP ALV导出excel 报 XML 错误的 /xl/sharedStrings.xml
abap
Z y..16 天前
abap po使用函数入参出参作为接口参数
abap
你好coder17 天前
VSCode连接SAP ABAP开发环境
ide·vscode·编辑器·sap·abap·cds
爱喝水的鱼丶17 天前
SAP-ABAP: Open SQL集合函数COUNT(统计行数)、SUM(数值求和)、AVG(平均值)、MAX/MIN(极值)深度指南
运维·数据库·sql·sap·报表·abap·程序
爱喝水的鱼丶19 天前
SAP-ABAP:ABAP Open SQL 深度解析:核心特性、性能优化与实践指南
运维·开发语言·数据库·sql·性能优化·sap·abap
DeveloperMrMeng19 天前
ABAP SQL更新DB小技巧 WITH INDICATORS
sql·sap·abap
爱喝水的鱼丶22 天前
SAP-ABAP:SAP ABAP OpenSQL JOIN 操作权威指南高效关联多表数据
运维·开发语言·数据库·sap·abap
LilySesy1 个月前
【案例总结】幽灵单据——消失的交货单号
数据库·ai·oracle·编辑器·sap·abap
SAP工博科技1 个月前
SAP ERP与微软ERP dynamics对比,两款云ERP产品有什么区别?
microsoft·sap·erp·dynamics
修电脑的猫2 个月前
Performance Monitoring on Production Systems in SAP ERP(ABAP性能优化)
性能优化·abap