Add the following code in index.html
:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<link type="image/x-icon" href="/images/favicon.ico" rel="shortcut icon">
<link type="image/x-icon" href="/images/favicon.ico" rel="icon">
<!-- <script id="sap-ui-bootstrap" src="https://sapui5.hana.ondemand.com/resources/sap-ui-core.js" -->
<script id="sap-ui-bootstrap" src="{{{ui5liburl}}}/resources/sap-ui-core.js"
data-sap-ui-theme="sap_belize_plus"
data-sap-ui-xx-bindingSyntax="complex"
data-sap-ui-compatVersion="edge"
data-sap-ui-preload="async"
data-sap-ui-language="en"
data-sap-ui-resourceroots='{
"dev.odataBasic": "./" }'
data-sap-ui-libs="sap.m,sap.ui.comp,sap.ui.core,sap.ui.layout">
</script>
<script>
sap.ui.getCore().attachInit(function () {
var ComponentContainer = new sap.ui.core.ComponentContainer({
height : "100%"
});
new sap.m.Shell({
app: ComponentContainer,
showLogout: true
}).placeAt("content");
var oComponent = sap.ui.component({
id: "comp",
name: "dev.odataBasic",
manifestFirst: true,
async: true
}).then(function(oComponent){
ComponentContainer.setComponent(oComponent);
});
});
</script>
</head>
<body class="sapUiBody" role="application">
<div id="content"></div>
</body>
</html>
Add the following code to Component.js
:
/*eslint no-console: 0, no-unused-vars: 0, no-use-before-define: 0, no-redeclare: 0*/
sap.ui.define([
"sap/ui/core/UIComponent",
"sap/ui/model/json/JSONModel",
"sap/ui/Device"
], function(UIComponent,JSONModel, Device) {
"use strict";
return UIComponent.extend("dev.odataBasic.Component", {
metadata: {
manifest: "json"
},
init: function() {
jQuery.sap.require("sap.m.MessageBox");
jQuery.sap.require("sap.m.MessageToast");
var oModel = new JSONModel(Device);
oModel.setDefaultBindingMode("OneWay");
this.setModel(oModel, "device");
sap.ui.core.UIComponent.prototype.init.apply(
this, arguments);
this.getSessionInfo();
},
destroy: function() {
// call the base component's destroy function
UIComponent.prototype.destroy.apply(this, arguments);
},
getSessionInfo: function() {
var aUrl = "/xsjs/exercisesMaster.xsjs?cmd=getSessionInfo";
this.onLoadSession(
JSON.parse(jQuery.ajax({
url: aUrl,
method: "GET",
dataType: "json",
async: false
}).responseText));
},
onLoadSession: function(myJSON) {
for (var i = 0; i < myJSON.session.length; i++) {
var config = this.getModel("config");
config.setProperty("/UserName", myJSON.session[i].UserName);
}
}
});
});
At the same level as index.html
create a file called manifest.json
. Enter the following code:
{
"_version": "1.4.0",
"start_url": "index.html",
"sap.app": {
"_version": "1.4.0",
"type": "application",
"resources": "resources.json",
"id": "odataBasic",
"title": "Basic OData App",
"description": "This is a SAPui5 application",
"applicationVersion": {
"version": "${project.version}"
},
//To-Do data source
},
"sap.fiori": {
"_version": "2.0.0",
"registrationIds": [],
"archeType": "transactional"
},
"sap.ui": {
"_version": "1.40.0",
"technology": "UI5",
"icons": {
"icon": "/images/favicon.ico",
"favIcon": "/images/favicon.ico"
},
"deviceTypes": {
"desktop": true,
"tablet": true,
"phone": true
},
"supportedThemes": [
"sap_hcb",
"sap_bluecrystal",
"sap_belize"
]
},
"sap.ui5": {
"config": {
"sapFiori2Adaptation": true
},
"rootView": {
"viewName": "dev.odataBasic.view.App",
"type": "XML",
"id": "app"
},
"dependencies": {
"minUI5Version": "1.40.0",
"libs": {
"sap.ui.core": {
"minVersion": "1.40.0"
},
"sap.ui.comp": {
"minVersion": "1.40.0"
},
"sap.m": {
"minVersion": "1.40.0"
},
"sap.ui.layout": {
"minVersion": "1.40.0"
}
}
},
"contentDensities": {
"compact": true,
"cozy": true
},
"handleValidation": true,
"models": {
"": {
"type": "sap.ui.model.json.JSONModel",
"settings": {
"defaultBindingMode": "TwoWay"
}
},
//To-Do bpModel
"config": {
"type": "sap.ui.model.json.JSONModel"
}
}
}
}