

You will find a Workspace folder. If you do not have a Web IDE account refer to create one and lay your foundation to learn SAPUI5.In Web IDE switch to development perspective by clicking on the icon “”. May be you have missed my previous article in this series SAPUI5 self-training tutorials.
Learning Sap For Beginners Code From The
Following MVC gives an application with better readability, maintainability and extensibility. In the above folder structure, we created separate files for the controller and the view, thereby separating the UI code from the logic code. I have explained in detail about MVC in my article. Sapui5 development from scratch SAPUI5 MVC paradigmSAPUI5 follows the Model View Controller paradigm. Repeat the process to create all folders and files as displayed in the image below.
What does SAPUI5 index.html holds?Index.html file holds the SAPUI5 bootstrap. If you want to run your application independently as stand-alone application, you should have an index.html file which will be the starting point of your application. Yes, for the time being keep in my mind that it is possible to have SAPUI5 applications without an index.html file and those applications are run inside SAP Fiori Launchpad. An SAPUI5 application with index.html file can be run as a stand-alone application.
Here we have used content delivery network CDN ‘’. I assume that you have basic knowledge of html.The tag with id=”sap-ui-bootstrap” is responsible for loading and initializing SAPUI5 core.The src attribute provides path to load SAPUI5 core library. SAPUI5 index.html Let’s understand the code of index.html file. It is taken care by the SAP Fiori Launchpad. It also initializes the SAPUI5 runtime as soon as the script is loaded and executed by the browser.So, in the case of SAPUI5 apps without an index.html, how bootstrapping takes place.
In the index.js file, we instantiate the XML view. The init event triggers when the bootstrapping is successful, and the index.js file is called in the callback function for the init event.Paste the below piece of code inside index.js file. Sapu5 index.js fileThe index.js file will be called only when the resource loading is successful. This attribute enhances app security as it helps avoid directly executable JavaScript code in index.html file.Data-sap-ui-resourceroots='’ tells SAPUI5 core that the resources in the namespace are in the same folder as index.html file.
This Asynchronous Module Definition helps in asynchronous loading of required modules and also separates the module loading from code execution.The resource objects are passed as parameters to the call back function. Sap.ui.define Asynchronous Module DefinitionSap.ui.define holds the array of required modules with their fully qualified path. The code inside function will only execute when all dependencies are loaded. Asynchronous Module DefinitionDid you notice the sap.ui.define at the beginning of index.js file? sap.ui.define is for Asynchronous module definition AMD and facilitates asynchronous loading of defined libraries. For the time being, just be familiar with the use of index.js file as the same principle follows for Component file.
Paste the below code in App.view.xml file. We have used XML view, but there are other view types supported by SAPUI5 application that I will explain at the end of this article.In index.js we instantiated the SAPUI5 XML view file.The view.xml file holds UI of SAPUI5 application. It is responsible for defining and rendering the UI of SAPUI5 application.
The code of this event handler function is written in the Controller file. As you can see in the code, we have attached this function to the press event of the button.Where do we write the logic of this event handler function. OnPress event handler function will be called when the button is pressed. Notice the properties, events, associations and aggregations as these are the few things for which you will have to refer the sapui5 sdk frequently.For the button control we have used the property text and the event press. The API Reference library gives all the details required to understand and use a SAPUI5 control. Have a look at the sapui5 sdk for Button control.
Code in App.Controller.js file sap.ui.define([Return Controller.extend("Amarmn.MyFirstApp.controller.
