on 2020 Jun 09 12:25 PM
Hi All,
I am working on Custom SAPUI5 Development, in which i need to display the image from the OData Service. I used sap.m.Image control to display the Image . I used the below code to set the image to the control.
Code:
var sNewURI = "/sap/opu/odata/sap/ZSERVICE_SRV/ImageSet(Guid=guid'" + sGUID + "',value2='" + svalue + "')/$value";
oDisplayImage.setSrc(sNewURI);
The above code is working, i can see the image in the application. and i set the Not Found Message in the sap.m.Image
alt property.
But in my application scenario, i have to display the proper business exception when the image is not loaded from the service.
So i tried to read the service and handle the error message in the alt property in sap.m.Image.
My code to read the Service:
oView.getModel().read("/ImageSet(Guid=guid'" + sGUID + "',value2='" + svalue + "')/$value", {
success: function (oResults, oResponse) {
},
error: function (oError) {
}
});
In above code when some error happened in the back end, it successfully triggers the error handler, and i can see the proper business exception in the error details tag.
But for the Success also it is triggers the same error handler and i received the error message saying,
no handler for data.
Please help me sort out this issue.
Thank you,
Regards,
JK.
Hi jayakrishnan.chnadramohan,
You can try ajax call, being able to handle the error using that. Check the below code.
Thanks,
jQuery.ajax({
type: "GET",
url: "/sap/opu/odata/sap/ZGEPMGS002_SRV/" + key + "/$value",
contentType: false,
processData: false,
xhrFields: {
responseType: "blob"
},
success: function (response, status, xhr) {
},
error: function (oError) {
var sErrMessageXML = oData.response.body;
sap.m.MessageBox.error(jQuery.parseXML(sErrMessageXML).querySelector("message").textContent);
}
});
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
72 | |
10 | |
10 | |
10 | |
10 | |
8 | |
8 | |
7 | |
5 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.