使用 yo 命令行向导给 SAP UI5 应用添加一个新的视图
在 使用 yo 创建好的 SAP UI5 项目里,使用命令行:
yo easy-ui5 project newview:
输入新的视图名称为 Products,创建新的控制器,以及在 manifest.json 里定义新的 route:
manifest.json routing 区域里三个节点增添了新属性:
target 区域增添了新的 id 和 name 同名的Products 视图,实现类型为 XML:
把 pattern 里字符串内容去掉,变成"":
webapp/view/Mainview.view.xml 是整个应用的外层容器。将 app 标签页里的内容全部删除:
创建出来的 Products 页面的内容为:
<mvc:View controllerName="tutorial.products.controller.Products" displayBlock="true" xmlns="sap.m" xmlns:mvc="sap.ui.core.mvc"> <Page id="Products" title="Available Products"> <content> <List items="{/Products}"> <StandardListItem type="Active" title="{ProductName}" /> </List> </content> </Page> </mvc:View>
使用 aggregation bindings,定义了一个 list.
使用命令行 yo easy-ui5 project newmodel 创建一个新模型:
所有到 data source 的数据请求,都会被发送到这个 url:
/V2/Northwind/Northwind.svc/.
Modify the uimodule/webapp/xsapp.json file to redirect the traffic to a destination.
修改 xsapp.json, 将请求重新路由到 destination.
{ "welcomeFile": "/flpSandbox.html", "routes": [ { "source": "^/V2/(.*)$", "authenticationType": "none", "destination": "Northwind", "csrfProtection": false }, { "source": "^(.*)", "target": "$1", "authenticationType": "xsuaa", "service": "html5-apps-repo-rt" } ] }
You already created a destination named Northwind in Cloud Foundry environment of SAP BTP. Now it’s time to add a mocked destination to your local setup as well.
在 uimodule 文件夹下面的 ui5.yaml 文件里:
定义一个本地 destination:
使用 npm ui5 启动工程。
最后的效果:
更多Jerry的原创文章,尽在:“汪子熙”:
- buildozer
- HttpServletRequest + Filter 添加 header
- element ui 下拉框编辑时无法修改 value值
- OPPO ColorOS再夺冠!鲁大师发布Q1季度UI排行!
- django的版本不一样,可能在建立外键关系的时候报错TypeError: __init__() missing 1 required positional argument: 'on_delete'
- 【OCP最新题库解析(052)--题11】Which is true about the (ADR)
- 【OCP最新题库解析(052)--题1】Which is true about the SYSTEM and SYSAUX表空间
- 【OCP最新题库解析(052)--题3】Which two are true about external tables?
- 【OCP最新题库解析(052)--题46】 Which two are true about transactions
- 【OCP最新题库解析(052)--题17】 Which three are true about the (AWR)?
- 【OCP最新题库解析(052)--题56】 Which three are true about the Automatic
- 【OCP最新题库解析(052)--题3】Which two are true about external tables?
- 【OCP最新题库解析(052)--题24】 Which two are true about Optimizer
- hbuilderX打包苹果证书的申请方法
- 【leetcode】高频题目整理_双指针篇( High Frequency Problems, Two Pointers )
- 【leetcode】高频题目整理_树结构篇( High Frequency Problems, Tree )
- 【leetcode】高频题目整理_数学篇( High Frequency Problems, Math )
- 【leetcode】高频题目整理_动态规划篇( High Frequency Problems, Dynamic Programming )
- leetcode】高频题目整理_栈篇( High Frequency Problems, Stack )
- 【leetcode】高频题目整理_深度优先遍历篇( High Frequency Problems, Depth-first Search )