cancel
Showing results for 
Search instead for 
Did you mean: 

Error During Use of Event Bus in Master Detail app.

former_member593030
Participant
0 Kudos
1,090

Hello All,

I am getting Error while using Event Bus (Subscribe and Publish).

So When the application is loaded first time from the launchpad , below code works perfectly.

But When i go back to my launchpad and come again to the app it is not working.

Error is

datajs-dbg.js:7960 Uncaught TypeError: Cannot read property 'refresh' of undefined at f.onRefresh1 (Master.controller.js?eval:1) at constructor.a.publish (EventBus-dbg.js:211) at success (Detail.controller.js?eval:1) at _ (ODataModel-dbg.js:1653) at ODataModel-dbg.js:3252 at datajs-dbg.js:1634 at p9 (datajs-dbg.js:2539) at Object.request (datajs-dbg.js:2591) at E2 (datajs-dbg.js:1612) at Object.o.request (datajs-dbg.js:7954)

// ------------------------------------ In Master Page ---------------------
onInit : function () {

var oEventBus = sap.ui.getCore().getEventBus();
oEventBus.subscribe("Master", "onRefresh1", this.onRefresh1  , this);

},

onRefresh1 : function () {
			this._oList.getBinding("items").refresh();
			var eventBus1 = sap.ui.getCore().getEventBus();
			eventBus1.publish("Detail","_bindView");
                         },


// ------------------------------------ In Detail Page ---------------------
onSave : function () {
     			         var eventBus = sap.ui.getCore().getEventBus();
			         eventBus.publish("Master","onRefresh1");
                
}

Can you please guide me what wrong I am doing?

Thanks in Advance.

Regards,

Sujoy

View Entire Topic
former_member593030
Participant
0 Kudos

Its is working now for me now. I just added below code.

var _oComponent = this.getOwnerComponent();

var oList = _oComponent.oListSelector._oList;

var oListBinding = oList.getBinding("items");

oListBinding.refresh(true);

var eventBus1 = sap.ui.getCore().getEventBus();

eventBus1.publish("Detail","_bindView");