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,078

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

Accepted Solutions (0)

Answers (4)

Answers (4)

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");

junwu
SAP Champion
SAP Champion
0 Kudos

you have to be more detailed.

when you go back to the app second time, it throws error immediately?

the full code

former_member593030
Participant
0 Kudos

Hello Jun,

No, When I come second time also App runs perfectly.

Only when I click on Submit (onSave is triggred) and then This error comes.

junwu
SAP Champion
SAP Champion
0 Kudos

this_oList how this is populated?

junwu
SAP Champion
SAP Champion
0 Kudos

not sure if it will help, but don't touch core

this.getOwnerComponent().getEventBus()

former_member593030
Participant
0 Kudos

Hi Jun,

I tried to debug my application and i found issue here.

Can you guide me here please?

this._oList.getBinding("items").refresh();
junwu
SAP Champion
SAP Champion
0 Kudos

don't use core.....

you can use event bus of your component....

former_member593030
Participant
0 Kudos

Sorry Jun, Didn't get that

Can you give with example?