on 03-30-2015 6:37 PM
Hello guys.
I got a simple ui5-oData CRUD which has the following:
a JS view
a JS controller
I'm able to choose a picture from my computer, but when I hit save button in my view it just goes null to the database. How can I properly get the image using my uploader component? Probably is not using getValue like the other fields. Any ideas.
I'm a newbie in ui5! Thanks in advance
My js view has the following ui5 component
var uploader = new sap.ui.unified.FileUploader(this.createId("uploader"),{
id: "fileUploader",
name: "myFileUpload",
buttonOnly: true,
uploadUrl: "upload/",
tooltip: "Upload your file to the local server",
fileType: ["jpg", "png"],
uploadOnChange: true
});
My controller has the following method
handleAcceptButtonPress: function(evt){
var controller = this;
var oModel = sap.ui.getCore().getModel();
var jsonData = {
"COMPANYDATAID": "0000000000",
"COMPANYNAME": controller.byId("company-name-textfield").getValue(),
"CORPORATENAME": controller.byId("corporate-name-textfield").getValue(),
"PHONENUMBER": controller.byId("phone-number-textfield").getValue(),
"CREATEDATE": null,
"ADDRESS": controller.byId("address-textfield").getValue(),
"SITE": controller.byId("cnpj-textfield").getValue(),
"CNPJ": controller.byId("site-textfield").getValue(),
"LOGO.LOGOID":controller.byId("uploader").getValue()
};
oModel.setHeaders({"content-type":"application/json;charset=utf-8"});
oModel.create("/CompanyRegister", jsonData, null, function(oData, res){
console.log("Partner creation successful");
var oContext = oModel.createEntry("/CompanyRegister", oData);
oContext.sPath = "/CompanyRegister("+oData.COMPANYDATAID+")";
controller.nav.to("Detail", oContext);
oModel.deleteCreatedEntry(oContext);
controller.clearForm();
}, function(err){
alert("Partner creation failed");
});
},
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Rodrigo, submitting a form and uploading image are 2 different operations:
1) upload uses
uploadUrl: "upload/"
so it is usually SICF service
2) form submit uses OData "CompanyRegister" service (entity set)
couple things - why do you call deleteCreatedEntry? Check the browser's Network traffic in dev tools and see what is coming in and out to that service CompanyRegister
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
84 | |
24 | |
12 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.