on 2018 Jan 14 5:14 PM
Hi there
I've a problem with OData where I can't access the error message when it goes wrong.
My controller has the following code - it all works fine.
onInit: function(){
this.getRouter().getRoute("display").attachPatternMatched(this.onObjectMatched, this);
},
onObjectMatched: function(oEvent){
var sObjectPath = this.oModel.createKey("DataSet", {
Var1: oEvent.getParameter("arguments").Var1,
Var2: oEvent.getParameter("arguments").Var2
});
this.getView().bindElement({
path: "/" + sObjectPath,
events: {
change: this.onBindingChange.bind(this)
}
});
},
onBindingChange: function(){
var oElementBinding = this.getView().getElementBinding();
if (!oElementBinding.getBoundContext()) {
this.getRouter().getTargets().display("notFound");
}
}
If the bindElement fails (because I manipulate the URL to access something I shouldn't, for example) I get an error in the console.
This error of course has an error message. My question is; how could I access this error message in the onBindingChange method? Is it possible? Or, even, anywhere (I could store it in the UIHelper if need be).
I've been looking all over Google and here but have not gotten nowhere.
In the bindElement method, I've tried to add the dataReceived event but that returns nothing. I've tried the attachRequestFailed on the oModel but that didn't work either.
Any help appreciated,
Thomas
Request clarification before answering.
Hi,
even though you're saying its not working for you, it is working for me.
you can add this to your Odata-Service:
var oModel = this.getView().getModel("myPrettyOdataModel");
oModel.attachRequestFailed(function (response) {
this.makeTheErrorInSomethingNice(response);
}, this);
Maybe you made a mistake somewhere?
Regards,
Samuel
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This depends on your used OData version. For v2 everything is fine; but with v4 many events are not supported.
User | Count |
---|---|
79 | |
21 | |
8 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.