Skip to Content

Display OData error message in bindelement( )

Jan 14 at 05:14 PM


avatar image

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
		path: "/" + sObjectPath,
		events: {
			change: this.onBindingChange.bind(this)
onBindingChange: function(){
	var oElementBinding = this.getView().getElementBinding();
	if (!oElementBinding.getBoundContext()) {

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,

untitled.png (4.7 kB)
10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Arjun Biswas Jan 15 at 04:21 AM

Hi Thomas Arnesen,

You can go through this link. It is specified there that, the bindElement method has an parameter events. You can define an custom event here, to detect wether your model path is correct or not.


Arjun Biswas.

10 |10000 characters needed characters left characters exceeded