Sap Ui 5 and Js Java Script and Fiori Contents
Sap Ui 5 and Js Java Script and Fiori Contents
Output:
1. window.alert() or alert()
2. document.write()
3. Console.log
4. innerHTML
F12= internet development toolbar or console
Event = activity performed by user on browser page
Function in JS
function name()
{
alert(“hello”);
(or)
document.write(“hello”);
(or)
console.log(“hello”);--- for developer to check the o/p on console
}
Creating an object
Var a = {empid:1, empname:”sai”,salary :1000,curcode: “inr”}
a is object
4 attributes and its values
Array in JS
Var name=[“val1”,”val2”];
Var aaa=[“1”,”sai”,”2”,”raghu”,]
aaa[0] =1
Aaa[aaa.length-1] is raghu
If we combine the concept of array and object, it becomes json
Array of objects [{},{},{},{}]
Var objproposal=document.getElementById(“propose”)
Var newElement= document.GetElementById(“h1”)
newElement.innerrtext=”hi ,this is sai”
objProposal.appendChild(newElement);
External javascript:
Make the script and save it as .js extension
Use at script as <script type=”text/javascript” src=”lifesaver.js”> </script>
Jquery
1. It is a javascript library
Why jquery
Write less and do more
MVC approach
MOdel-View-Control
A design pattern to create end to end application.
Using MVC we make our application ready for future changes
Maximum reusability and extensibility
Index.html
Code to create the view object in index.html and place it in HTML
Xml
eXtensible Markup Language
The main purpose of the xml was to exchange the data between multiple technologies. Unlike
HTML, in XML we will have our own tag names
Aggregation
When we want to reuse the functionality of a class, we create a inheritance.so base
class attributes in functions will be inherited to the children
Association:
Relationship between two objects
Divided 2 parts
1.aggregation: loose binding- both objects can work independently
2. Composition - tight binding- objects cannot function independently
Eg: laboratory, free lance laboratory in college
Cardinality: 1:1ww , 1:n
MODEL:
Object of DATA of our application.
How your ui controls will receive the data what u have in these models
View
Small ip field for to store the data for user name
Model
Inside having some Attribute
Or variable( to store the data)
At console to check
sap.ui.getCore().getModel().getProperty("/prodStr")
sap.ui.getCore().getModel().getProperty("/prodTab")[0]
Or
sap.ui.getCore().getModel().getProperty("/prodTab/1")]
Then binding process
What is json
Array of objects
Ex1(structure and tabel)
{ “prodStr”:{“prodName”:”laptop”,”price”:”500”},
“prodTab”:[ {“prodName”: “laptop”,”price”:”500”},
{“prodName”: “laptop”,”price”:”500”},
{“prodName”: “laptop”,”price”:”500”},
{“prodName”: “laptop”,”price”:”500”}
]
}
How to validate json
Website: www.jsonlint.com
Column
1. Title of the column
2. Templet = control what type of ui element we want the column to be
3. Along with the template property we need to also do the binding (from which property of
JSON , it will pick up values)
var oCol1= new sap.ui.table.Column (“col1”,{
label: new sap.ui.commons.Label({ text: “Employee Id”}),
Template: new sap.ui.commons.TextView().bindText(“superman>empId”)
});
Xml model
1.Unlike html,xml can have custom tags
2.tansfer the data between languages
3. Xml can be processed by programming languages using DOM model
<emploree>
<row>
<empId></empId>
<eName></eName>
<gender></gender>
</row>
<row>
<empId></empId>
<eName></eName>
<gender></gender>
</row>
</employee>
Internationalization
Supporting the application developed in UI5 with multi-lingual support
Global Variables
sap.ui.getCore().getModel()
All global variables for the controllers are defined in oninit method
With prefix, this keyword
Formatters
Many times when we develop application, we would need to format our data at runtime
Syntax:
UIProp:{
path:”model path”,
formatter: formatter_function,function(value){}
}
Value:{
path:”model>eName”,
formatter:function(input){convert….. and…..return}
}
Fiori :
User experience of a UI5 application.
1. Device compatibility
2. Responsive
3. Platform independent
4. Same look and feel
5. Role based
LIST CONTROL
LIST MODE
Index.html
sap.m.App => sap.m.SplitApp
Fragments
Lightweight UI parts. A fragment would not have any controller,the functionality of the fragment
will be defined by the controller who invokes the fragment.
Save as
Myname.fragment.js
Custom control
A custom control is a control which developer can define in case if a standard sap control
doesn’t serve the purpose.
Syntax:
sap.ui.core.Control.extend(“ControlName”,{
Metadata:{properties:,events:,methods:},
renderer: function(oRm,oControl){},
Init : function(){}
});
Sap ui5 does not provide heading control and google map control
Create object of api’s(sapui5 framework->sap.m,sap.ui.commons) andadd it to the HTML body
Api’s
google.maps.Map => This will create a new map object
google.maps.Marker => to mark a location on the map
google.maps.Geocode => pass the address, returns the exact longitude and latitude
Component.js
UI component which encapsulates entire functionality of our Application
1.navigation(router information)
2. Versioning information
3. Dependencies (depends on some libraries)
4. Global methods and variables
5. Configuration
6. Model
7. Instantiate the main App view
8. Initialization (router and fragment initialization)
1.we want structure our app by keeping all the entities in separate folder
2. Integrating the app with sap launchpad (fiori launchpad its a shell and container AND
container will contain tiles and each tiles navigate u to corresponding app. That app loaded into
a container in that container u have to bring the reusable entity and place it into the same
container)
Index,html
| component.js
Shell ------> |
| main app view
Component container |
Split app-----------------master view and detail view
In index.html we create shell control this shell control will contain component container
Each applications component is a reusable consumable entity which can be used to create a
launchpad screen
Odata:
open data protocol,this allows us to consume the data over the http or internet
You do not need to worry about underlying database and its queries.
Odata.org
Any odata service we use has 3 parts
1. Service document - define the entity sets of the service
2. Metadata document - allows us to look at the metadata $metadata
3. Data - we can see the entity data using /EntitysetName at the end of the service url
/Products?$format=json
Router:
Router concept is allows u to navigate any view without creating the instance of the view
Just define the properties of the view and sapui5 framework automatically will create the object
of the views.
Metadat:{
Routing:{
Config:{
viewType:””,
view Path:”” },
Routes:[{
Pattern:””,
Name:””,
View:””,
targetAggregation:””,
targetControl:””}]
},
},
It allows u to create the object of the view without writing the code, Router will only initialize the
views
Features of odata
1. Select some of the fields $select=field names
2. Paging $top, $skip
3. $expand to check dependent entity data together
4. $format= json
BAPI_EMP_PRODUCT_GET_LIST
BAPI_EMP_PRODUCT_GET_DETAILS
BAPI_EMP_PRODUCT_CREATE
BAPI_EMP_PRODUCT_GET_UPDATE
BAPI_EMP_PRODUCT_GET_DELETE
Products
Orders
Suppliers