on 02-15-2017 11:32 AM
sap.ui
.controller(
"club.club.Create",
{
onInit : function() {
},
handleBackPress : function(oEvent) {
var oRouter = sap.ui.core.UIComponent
.getRouterFor(this);
oRouter.navTo("schedule");
},
handleSubmitPress : function(oEvent) {
var oId = this.getView().byId("MatchId");
oId.setEditable(true);
oId.setValue("");
var oId = this.getView().byId("MatchDate");
oId.setEditable(true);
oId.setValue("");
var oId = this.getView().byId("HomeTeam");
oId.setEditable(true);
oId.setValue("");
var oId = this.getView().byId("AwayTeam");
oId.setEditable(true);
oId.setValue("");
var oId = this.getView().byId("MatchType");
oId.setEditable(true);
oId.setValue("");
var oId = this.getView().byId("Week");
oId.setEditable(true);
oId.setValue("");
var oId = this.getView().byId("Location");
oId.setEditable(true);
oId.setValue("");
var oForm = this.getView().byId("createForm");
var MatchId = this.getView().byId("MatchId").getValue();
console.log(MatchId);
var MatchDate = this.getView().byId("MatchDate")
.getValue();
var HomeTeam = this.getView().byId("HomeTeam")
.getValue();
var AwayTeam = this.getView().byId("AwayTeam")
.getValue();
var MatchType = this.getView().byId("MatchType")
.getValue();
var Week = this.getView().byId("Week").getValue();
var Location = this.getView().byId("Location")
.getValue();
OData
.request(
{
requestUri : "http://eccehp7.erp.com:8000/sap/opu/odata/sap/ZYK_SCHEDULE_SRV_01",
method : "GET",
user : "",
password : "",
headers : {
"X-Requested-With" : "XMLHttpRequest",
"Content-Type" : "application/json",
"DataServiceVersion" : "2.0",
"X-CSRF-Token" : "Fetch",
"Access-Control-Allow-Origin" : "*",
"Access-Control-Allow-Methods" : "GET,PUT,POST,DELETE,OPTIONS",
"Access-Control-Allow-Headers" : "Origin, Content-Type, Authorization, Accept, X-Request-With",
"Access-Control-Allow-Credentials" : "true",
'Authorization' : 'Basic '
+ btoa("username"
+ ':password')
}
},
function(data, response) {
OData.request({
requestUri : "http://eccehp7.erp.com:8000/sap/opu/odata/sap/ZYK_SCHEDULE_SRV_01/SheduleSet",
method : "POST",
headers : {
"X-Requested-With" : "XMLHttpRequest",
"Content-Type" : "application/atom-xml",
"DataServiceVersion" : "2.0",
"Accept" : "application/atom-xml,",
"X-CSRF-Token" : response.headers['x-csrf-token'],
"Access-Control-Allow-Origin" : "*",
"Access-Control-Allow-Methods" : "GET,PUT,POST,DELETE,OPTIONS",
"Access-Control-Allow-Headers" : "Origin, Content-Type, Authorization, Accept, X-Request-With",
"Access-Control-Allow-Credentials" : "true",
'Authorization' : 'Basic '
+ btoa("username"
+ ':password')
},
data : {
MatchId : MatchId,
MatchDate : MatchDate,
HomeTeam : HomeTeam,
AwayTeam : AwayTeam,
MatchType : MatchType,
Week : Week,
Location : Location,
}
},
function(data,
request) {
var oSubDialog = new sap.ui.commons.Dialog(
{
title : "Created",
content : [ new sap.ui.commons.Label(
{
text : "Data Created Successfully"
}) ]
});
oSubDialog
.open();
oSubDialog
.addButton(new sap.ui.commons.Button(
{
text : "Ok",
press : function() {
oSubDialog
.close();
}
}));
sap.ui
.getCore()
.getModel()
.refresh();
},
function(err) {
//alert("Create Error");
console.log(err);
});
}, function(err) {
var request = err.request;
var response = err.response;
alert("Error in Post Method"
+ request + "Response"
+ response);
});
}
});
this is my controller file
User | Count |
---|---|
75 | |
9 | |
8 | |
7 | |
7 | |
6 | |
6 | |
6 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.