SAP Web IDE Hybrid Application Toolkit Introduction and Demo
Here is the code needed to add the button for adding barcode reader to the searchfield (time 14:10)
Master.view.xml:
<contentRight>
<Button id="barcodeButton" icon="sap-icon://bar-code" tooltip="Bar Code Scanner" press="onBarCodeScan"></Button>
</contentRight>
Master.controller.js
onBarCodeScan: function() {
var that = this;
var code = "";
if (!cordova.plugins.barcodeScanner) {
sap.m.MessageBox.show("barCode scanning not supported", sap.m.MessageBox.Icon.INFORMATION, "Bsrcode scanning");
return;
}
cordova.plugins.barcodeScanner.scan(
function (result) {
code = result.text;
that.getView().byId("searchField").setValue(code);
that.onSearch();
},
function (error) {
alert("Scanning failed: " + error);
}
);
},
Here is the code needed to add the button for adding the contact to mobile device (time 5:00)
Detail.view.xml:
<Button xmlns="sap.m" text="add to contact" press="addContact"></Button>
Detail.controller.js:
jQuery.sap.require("sap.m.MessageBox");
addContact: function(oEvent) {
if (!navigator.contacts) {
sap.m.MessageBox.show("Contacts API only supported on Devices/Simulators", sap.m.MessageBox.Icon.INFORMATION, "Add Contact");
return;
}
var oView = this.getView();
var sEntityPath = "/" + oEvent.getSource().getBindingContext().getPath().slice(1) + "/SupplierDetails";
var bpData = oView.getModel().getData(sEntityPath);
//Get Contacts data
var name = bpData.SupplierName;
var phone = bpData.PhoneNumber;
var email = bpData.EmailAddress;
var contact = navigator.contacts.create();
contact.name = { givenName: name };
var phoneNumbers = [];
var emails = [];
phoneNumbers[0] = new ContactField("work", phone, true);
emails[0] = new ContactField("email", email, false);
contact.phoneNumbers = phoneNumbers;
contact.emails = emails;
contact.save();
sap.m.MessageBox.show("Successfully saved into Device Contacts ", sap.m.MessageBox.Icon.SUCCESS, "Add Contact");
},
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
11 | |
10 | |
10 | |
10 | |
8 | |
7 | |
7 | |
7 | |
7 | |
6 |