cancel
Showing results for 
Search instead for 
Did you mean: 

Model Sharing between different apps

SatyaKudumula
Explorer
0 Kudos

Hi Experts,

My requirement: JsonModel/Model sharing between multiple BSP apps.

BSP 1 named as Parent App

BSP 2 named as Child App

I am able to call the model from child to parent app and vice versa by using eventbus.

I have a couple of doubts :

  1. can we use this eventbus(model sharing between apps) in production level?
  2. Are there any disadvantages and advantages by using eventbus
  3. Is it possible if the huge amount of data(more than 50,000 records) transfer between apps by eventbus?

Thanks in advance.

Regards,

SG

Accepted Solutions (0)

Answers (2)

Answers (2)

former_member306541
Participant

You can pass any data to your child app within componentData, when you create your Component like this:

var oComponent = sap.ui.getCore().createComponent({
	name: "your.namespace.ChildApp",
	id: "ChildApp",
	componentData: {
		oJSONModel: oYourJSONModel
	}
});
var oComponentContainer = this.getView().byId("idComponentContainer");
oComponentContainer.setComponent(oComponent);

In your child app component.js read oJSONModel like this:

var oComponentData = this.getComponentData();
var oJSONModel;
if(oComponentData && oComponentData.oJSONModel){
	oJSONModel = oComponentData.oJSONModel;
} else {
	// Fallback, if parent app passes no JSONModel
	oJSONModel = new JSONModel();
}

Parent and child app are working on the same model now.

junwu
Active Contributor
0 Kudos

event is not meant for data passing, I think.

I don't know how you integrate two ui5 app, reuse component? there are different ways, you can use sap.ui.core to share data

SatyaKudumula
Explorer
0 Kudos

Hi Jun Wu,

I used the component container to integrate two bsp apps. and to achieve my requirement I used eventBus and I got success in sharing data between two apps.

but my doubt eventbus is the right way to do? are there any disadvantages.

Regards,

SG