-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstep12.html
152 lines (135 loc) · 4.62 KB
/
step12.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
<!DOCTYPE html>
<html>
<head>
<meta http-equiv='X-UA-Compatible' content='IE=edge' />
<meta charset="UTF-8">
<title>Mobile OData Demo</title>
<script id='sap-ui-bootstrap'
src='https://openui5.hana.ondemand.com/resources/sap-ui-core.js'
data-sap-ui-theme='sap_mvi'
data-sap-ui-libs='sap.m'
data-sap-ui-xx-test-mobile = "true"
data-sap-ui-xx-fakeOS = "android">
</script>
<script>
(function() {
var app = new sap.m.App("ODataDemo");
// main page
var appStartPage = new sap.m.Page("startPage", {
title : "List Overview",
footer : new sap.m.Bar({
contentMiddle : [ new sap.m.Label({
text : "Mobile OData Demo"
}) ]
})
});
var Bar = new sap.m.Bar({
contentLeft: [],
contentMiddle: [new sap.m.Label('BarTitle', {text: "Products"})],
contentRight: []
});
appStartPage.setCustomHeader(Bar);
var oListStandardNoImageNoHeader = new sap.m.List({
inset : false
});
itemTemplate = new sap.m.StandardListItem({
title : '{ProductName}',
tap: function(oEvent) {
detailPage.setBindingContext(oEvent.getSource().getBindingContext());
app.to("detailPage");
},
type: "Navigation",
description: "{ProductID}",
customData: [
new sap.ui.core.CustomData({
key: "id",
value: "{ProductID}"
}),
]
});
oListStandardNoImageNoHeader.bindAggregation("items", {
path: "/Products",
template: itemTemplate
});
appStartPage.addContent(oListStandardNoImageNoHeader);
// detail page
var listDetail1 = new sap.m.List({
headerText: "Product Information",
inset: false
});
var listDetail2 = new sap.m.List({
headerText: "Supplier Details",
inset: false
});
listDetail1.addItem(new sap.m.DisplayListItem( { value: "{ProductID}" , label: "ID" }));
listDetail1.addItem(new sap.m.DisplayListItem( { value: "{ProductName}" , label: "Name" }));
listDetail1.addItem(new sap.m.DisplayListItem( { value: "{UnitPrice}" , label: "Price" }));
listDetail2.bindContext("Supplier");
listDetail2.addItem(new sap.m.DisplayListItem( { value: "{SupplierName}" , label: "Company" }));
listDetail2.addItem(new sap.m.DisplayListItem( { value: "{Address}" , label: "Street" }));
listDetail2.addItem(new sap.m.DisplayListItem( { value: "{City}" , label: "City" }));
listDetail2.addItem(new sap.m.DisplayListItem( { value: "{Country}" , label: "Country" }));
listDetail2.addItem(new sap.m.DisplayListItem( { value: "{PostalCode}", label: "Postal Code"}));
var detailPage = new sap.m.Page("detailPage", {
title : "Product Details",
showNavButton : true,
navButtonText : "Products",
navButtonTap : function() {
app.back();
},
content: [
listDetail1,
listDetail2
]
});
// data access
function getServiceUrl(sServiceUrl) {
var sOrigin = window.location.protocol + "//" + window.location.hostname
+ (window.location.port ? ":" + window.location.port : "");
if (!jQuery.sap.startsWith(sServiceUrl, sOrigin)) {
return "proxy/" + sServiceUrl.replace("://", "/");
} else {
return sServiceUrl.substring(sOrigin.length);
}
};
var sServiceUrl = "https://cors-anywhere.herokuapp.com/services.odata.org/Northwind/Northwind.svc/";
// sServiceUrl = getServiceUrl(sServiceUrl);
var busyDialog = (busyDialog) ? busyDialog : new sap.m.BusyDialog('busyDialog',{text:'Loading Northwind Data', title: 'Loading'});
$(function(){
var oModel = new sap.ui.model.odata.ODataModel(sServiceUrl, true);
oModel.setSizeLimit(20);
oModel.attachRequestFailed(function(evt) {
alert("Server error: " + evt.getParameter("message") + " - " + evt.getParameter("statusText"));
});
jQuery.sap.log.debug(oModel);
// BusyDialog
oModel.attachRequestSent(function(){busyDialog.open();});
oModel.attachRequestCompleted(function(){busyDialog.close();});
oCore = sap.ui.getCore().setModel(oModel);
});
app.addPage(appStartPage).addPage(detailPage);
app.placeAt("content");
// history handling
jQuery.sap.require("jquery.sap.history");
jQuery.sap.history({
routes: [{
path: "detailPage",
handler: function(params, navType) {
if (navType === jQuery.sap.history.NavType.Back) app.back();
else {
detailPage.setBindingContext(params.ctx);
app.to("detailPage");
}
}
}],
defaultHandler: function(navType) {
(navType === jQuery.sap.history.NavType.Back) ? app.back() : app.to("startPage");
}
});
})();
</script>
</head>
<body id="body" class="sapUiBody">
<div id="content"></div>
</body>
</html>