<!DOCTYPE HTML><html><head><metahttp-equiv="X-UA-Compatible"content="IE=edge"><metahttp-equiv='Content-Type'content='text/html;charset=UTF-8'/><scriptsrc="resources/sap-ui-core.js"id="sap-ui-bootstrap"data-sap-ui-libs="sap.m"data-sap-ui-theme="sap_bluecrystal"></script><!-- only load the mobile lib "sap.m" and the "sap_bluecrystal" theme --><script>
sap.ui.localResources("helloworld");
var app = new sap.m.App({initialPage:"idHelloWorld1"});
var page = sap.ui.view({id:"idHelloWorld1", viewName:"helloworld.HelloWorld", type:sap.ui.core.mvc.ViewType.XML});
app.addPage(page);
app.placeAt("content");
</script></head><bodyclass="sapUiBody"role="application"><divid="content"></div></body></html>
<core:Viewxmlns:core="sap.ui.core"xmlns:mvc="sap.ui.core.mvc"xmlns="sap.m"controllerName="helloworld.HelloWorld"xmlns:html="http://www.w3.org/1999/xhtml"><Pagetitle="Title"><content><Labeltext="This is Hello World"></Label></content></Page></core:View>
编写Controller
对于MVC结构而言自然少不了控制器,下面我们编写一个controller.
sap.ui.controller("helloworld.HelloWorld", {
/**
* Called when a controller is instantiated and its View controls (if available) are already created.
* Can be used to modify the View before it is displayed, to bind event handlers and do other one-time initialization.
* @memberOf helloworld.HelloWorld
*/// onInit: function() {//// },/**
* Similar to onAfterRendering, but this hook is invoked before the controller's View is re-rendered
* (NOT before the first rendering! onInit() is used for that one!).
* @memberOf helloworld.HelloWorld
*/// onBeforeRendering: function() {//// },/**
* Called when the View has been rendered (so its HTML is part of the document). Post-rendering manipulations of the HTML could be done here.
* This hook is the same one that SAPUI5 controls get after being rendered.
* @memberOf helloworld.HelloWorld
*/// onAfterRendering: function() {//// },/**
* Called when the Controller is destroyed. Use this one to free resources and finalize activities.
* @memberOf helloworld.HelloWorld
*/// onExit: function() {//// }
});