Skip to Content
0
Jan 23, 2014 at 12:47 PM

Want to know the output of the code and why?

27 Views

Hi everyone,

I have written the following code in NWDS and want to know that what should be the output of that code,

index.html

================================================================================================================

<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge">

<script src="resources/sap-ui-core.js"
id="sap-ui-bootstrap"
data-sap-ui-libs="sap.ui.commons"
data-sap-ui-theme="sap_goldreflection">
</script>


<!-- add sap.ui.table,sap.ui.ux3 and/or other libraries to 'data-sap-ui-libs' if required -->

<script>
sap.ui.localResources("test");


jQuery.sap.registerModulePath('Application', 'Application');



// Launch application
jQuery.sap.require("Application");
var oApp = new Application({
root : "content"
}); // instantiate your application and mark the HTML element with id "content" as location for the UI


</script>

</head>
<body class="sapUiBody" role="application">
<div id="content"></div>
</body>
</html>

Application.js

===========================================================================================================

jQuery.sap.declare("Application");
jQuery.sap.require("sap.ui.app.Application");

sap.ui.app.Application.extend("Application", {

init : function() {
// set global models
var model = new sap.ui.model.json.JSONModel();
sap.ui.getCore().setModel(model, "model");
},

main : function() {
// create app view and put to html root element
var root = this.getRoot();
sap.ui.jsview("App", "test.App").placeAt(root);
}


});

App.view.js

==============================================================================================================

sap.ui.jsview("test.App", {

/** 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 test.App
*/
getControllerName : function() {
return "test.App";
},

/** 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 test.App
*/
createContent : function(oController) {

this.panel = new sap.ui.commons.Panel();
this.layout = new sap.ui.commons.layout.MatrixLayout();

this.txt_field = new sap.ui.commons.TextField("txt_field");

this.layout.createRow(txt_field);
this.panel.addContent(this.layout);

return this.panel;
}

});

App.controller.js

============================================================================================================

Nothing I have written in the controller.js. The default code that has came in the controller. All are commented.

Now if I run the index.html file what I should get in the output? I am getting the following output,

I want to know whether I am getting the correct output and why this output is coming? I want that a text field to come, nothing more.

Attachments

Capture.JPG (19.8 kB)