Skip to Content
author's profile photo Former Member
Former Member

SAPUI5 Publish and subscribe problem


I am using publish/subscribe to pass data from master to detail view.

Master controller.js

var bins = { source: source, destination: destination };
var oEventBus = sap.ui.getCore().getEventBus();
oEventBus.publish("Master", "GetBatches", { bins });

Detail controller.js

onInit: function() {
    this.oInitialLoadFinishedDeferred = jQuery.Deferred();
    var oEventBus = sap.ui.getCore().getEventBus();
    oEventBus.subscribe("Master", "GetBatches", this.onGetBatches, this);

    this.getRouter().attachRouteMatched(this.onRouteMatched, this);		
	onGetBatches : function (sChanel, sEvent, oData) {
//		if(sEvent === "GetBatches"){
			var sourceBin = oData.source;
			var destBin   = oData.destination;
//		} 	

The problem is that when the detail controller gets into onInit, it does not call the function onGetBatches at all but instead it jumps to the onRouteMatched.

Does anyone have an idea, why onGetBatches is not called?



Add comment
10|10000 characters needed characters exceeded

1 Answer

  • Best Answer
    Posted on Feb 14, 2017 at 09:56 AM


    Why do you want to use the event bus to pass parameters from one view to the other? Why don't you use a navigation parameter when you navigate from master to detail? The walkthrough shows how to do it:



    Add comment
    10|10000 characters needed characters exceeded