zoukankan      html  css  js  c++  java
  • Step 15: Nested Views

    Step 15: Nested Views

    嵌套view
    当画面的控件变多后,最好不要只用一个view,分成多个view比较利于后面的维护和重用,所以就要使用的嵌套view

    webapp/view/App.view.xml

    <mvc:View
    	controllerName="sap.ui.demo.walkthrough.controller.App"
    	xmlns="sap.m"
    	xmlns:mvc="sap.ui.core.mvc"
    	displayBlock="true">
    	<Shell>
    		<App class="myAppDemoWT">
    			<pages>
    				<Page title="{i18n>homePageTitle}">
    					<content>
    						<mvc:XMLView viewName="sap.ui.demo.walkthrough.view.HelloPanel"/>
    					</content>
    				</Page>
    			</pages>
    		</App>
    	</Shell>
    </mvc:View>
    

    把Panel里的内容,封装成一个view

    webapp/view/HelloPanel.view.xml (New)

    <mvc:View
       controllerName="sap.ui.demo.walkthrough.controller.HelloPanel"
       xmlns="sap.m"
       xmlns:mvc="sap.ui.core.mvc">
       <Panel
          headerText="{i18n>helloPanelTitle}"
          class="sapUiResponsiveMargin"
          width="auto" >
          <content>
             <Button
                text="{i18n>showHelloButtonText}"
                press=".onShowHello"
                class="myCustomButton"/>
             <Input
                value="{/recipient/name}"
                valueLiveUpdate="true"
                width="60%"/>
             <FormattedText
                htmlText="Hello {/recipient/name}"
                class="sapUiSmallMargin sapThemeHighlight-asColor myCustomText"/>
          </content>
       </Panel>
    </mvc:View>
    

    把原来App.view.xml里panel部分的内容移动到这里。并指定一个新的controller。

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

    sap.ui.define([
       "sap/ui/core/mvc/Controller",
       "sap/m/MessageToast"
    ], function (Controller, MessageToast) {
       "use strict";
       return Controller.extend("sap.ui.demo.walkthrough.controller.HelloPanel", {
          onShowHello : function () {
             // read msg from i18n model
             var oBundle = this.getView().getModel("i18n").getResourceBundle();
             var sRecipient = this.getView().getModel().getProperty("/recipient/name");
             var sMsg = oBundle.getText("helloMsg", [sRecipient]);
             // show message
             MessageToast.show(sMsg);
          }
       });
    });
    

    把原来在App.controller.js里的按钮点击事件的代码移动到这里。

    webapp/controller/App.controller.js

    sap.ui.define([
       "sap/ui/core/mvc/Controller"
    ], function (Controller) {
       "use strict";
       return Controller.extend("sap.ui.demo.walkthrough.controller.App", {
       });
    });
    

    把原来在App.controller.js里的按钮点击事件的代码删除掉。

    vx:xiaoshitou5854

  • 相关阅读:
    Micorosoft 2013年笔试题
    Dropbox推荐使用
    swift_枚举 | 可为空类型 | 枚举关联值 | 枚举递归 | 树的概念
    swift_简单值 | 元祖 | 流程控制 | 字符串 | 集合
    Swift函数的定义
    swift_Dictionary 字典
    Xcode创建Object-C程序
    Spring事务管理者与Spring事务注解--声明式事务
    JDK注解替代Hibernate的Entity映射
    关于JAVA EE项目在WEB-INF目录下的jsp页面如何访问WebRoot中的CSS和JS文件
  • 原文地址:https://www.cnblogs.com/xiaoshiwang/p/15188195.html
Copyright © 2011-2022 走看看