作者:穿行印象
http://blog.sina.com.cn/s/blog_7a9486880101qgyv.html
Kapsel EncryptedStorage Plugin的作用:以加密的形式将数据存储到移动设备端,使用API可以存储、读取其中的数据。例如,将数据存储在EncryptedStorage中:
storage.setItem(key,
value,
storageSuccessCallback,
storageErrorCallback);
将数据从EncryptedStrage读取数据:
storage.getItem(airlineDataKey,
function(value) {airlineData = JSON.parse(value);},
storageErrorCallback);
结合SAP UI5的SDK,使用GET或者POST方法读取、修改OData服务的数据。例如,如下的UI:

当点击一个航空公司时,触发getFlights方法可以获取该行空公司的航班信息:
getFlights : function(carrid)
{
//
Get a reference to the view and the list template
var view
= sap.ui.getCore().byId("flights");
var oTemplate
= view.getTemplate();
//
Get a reference to the list and set the model
var oList
= sap.ui.getCore().byId("FlList");
oList.setModel(oModel);
//
Bind the carrierFlights items and template
oList.bindItems("/CarrierCollection('" +
carrid + "')/carrierFlights",
oTemplate, null, null);
app.to("flights");
}
flights的view定义如下:
sap.ui.jsview("app.flights",
{
oTemplate
: new sap.m.CustomListItem({
type
: sap.m.ListType.Navigation,
press
: function(evt)
{
var cont
= sap.ui.getCore().byId("flights").getController();
cont.getDetails(evt, this.getModel());
},
content
: [ new sap.m.FlexBox({
items
: [ new sap.m.HBox({
justifyContent
: "Start",
width
: "50%",
items
: [ new sap.m.Text({
text
: "{flightDetails/cityFrom}"
})
]
}), new sap.m.HBox({
justifyContent
: "End",
width
: "50%",
items
: [ new sap.m.Text({
text
: "{flightDetails/cityTo}"
})
]
})
]
}), new sap.m.FlexBox({
items
: [ new sap.m.Text({
text
: {
path
: "fldate",
type
: oDateTime
}
})
]
}) ]
}),
getControllerName
: function()
{
return "app.flights";
},
getTemplate
: function()
{
return this.oTemplate;
},
createContent
: function(oController)
{
var list
= new sap.m.List("FlList",
{
items
: [
]
});
return new sap.m.Page({
showNavButton
: true,
navButtonText
: "Back",
navButtonPress
: function()
{
app.back();
},
title
: "Flights",
content
: [ list ]
});
}
});
航班信息的UI长这个样子:

还可以使用POST方法修改数据,这里略去不表。