Skip to Content
0
Apr 10, 2014 at 10:51 AM

How to create a simple app using the MVC approach?

30 Views

Hello gurus i'm trying to learn the SAPUI5 and i'm trying to create a simple app using the MVC i created the app and trying to add a lable to the view but there is nothing appear when i run it the code for the HTML page

<!DOCTYPE HTML>

<html>

<head>

<meta http-equiv="X-UA-Compatible" content="IE=edge">

<meta http-equiv='Content-Type' content='text/html;charset=UTF-8'/>

<script src="https://sapui5.hana.ondemand.com/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_mvi" theme -->

<script>

sap.ui.localResources("mytestapp");

var view = sap.ui.view({id:"idshell1", viewName:"mytestapp.shell", type:sap.ui.core.mvc.ViewType.JS});

view.placeAt("content");

</script>

</head>

<body class="sapUiBody" role="application">

<div id="content"></div>

</body>

</html>

the code for the view

sap.ui.jsview("mytestapp.shell", {

/** Specifies the Controller belonging to this View.

* In the case that it is not implemented, or that "null" is returned, this View does not have a Controller.

* @memberOf mytestapp.shell

*/

getControllerName : function() {

return "mytestapp.shell";

},

/** Is initially called once after the Controller has been instantiated. It is the place where the UI is constructed.

* Since the Controller is given to this method, its event handlers can be attached right away.

* @memberOf mytestapp.shell

*/

createContent : function(oController) {

var oLabel = new sap.ui.commons.Label("l1");

oLabel.setText("Test label");

oLabel.placeAt("content");

}

});

i dont know what is wrong or if i should use a container to display my controls

any help will be appreciated

thanks in advance