Skip to Content

Want to know the output of the code and why?

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.

Capture.JPG (19.8 kB)
Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Jan 23, 2014 at 01:54 PM

    Hi Soumya ,

    may i understand something wrong, but are you able to open your application in browser, by using the url?

    Then you could use the developer tools of the browser.

    In Internet Explorer push F12 on your keyboard,

    or use chrome, or firefox with the firebug plugin.

    There you find a tab named "console" which will show javascript errors.

    According to your code, perhaps there are problems with your projectsettings and the

    SAPUI5 framework cannot be found. You can see that in browser as mentioned before.

    Best wishes

    Kai

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jan 23, 2014 at 03:36 PM

    You should have got a panel with a text box in it.

    As Kai suggested, open developer tools (F12) , goto Console and check for any errors.

    regards

    Krishna

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.