Skip to Content
0
Dec 13, 2018 at 03:05 PM

Create dinamically component container

255 Views

Hello SCN friends,

Please I need your help with something, I have used ComponentContainer to open an app inside a another app defining statically in the XML View. So now I need to do this but in the handle of route matched of the parent app in the controller of the parent view. When I do it, this issues an error saying that the "The name of the component is undefined.", but if I put this code in the onInit method works as expected.

What could be wrong here?.

XML Code (works well)

<core:ComponentContainer id="containerForChildComponent" autoPrefixId="true" settings="{id: 'childComponent'}" height="100%" manifest="true" async="true" lifecycle="Container" usage="reuseAnotherComponent"/>

Controller of the parent app, method handleRouteMatched.

this.byId("pageAppCont").addContent( new sap.ui.core.ComponentContainer({
				 	id : "containerForChildComponent",
					autoPrefixId : true,
				  	settings : { id: "childComponent"},
					height : "100%",
				 	manifest : true,
				  	async : true,
				  	lifecycle : "Container",
				  	//name : "confCortes",
				  	usage : "reuseAnotherComponent"
				 }));

the pageAppCont is the Page object of the view of the parent app.

This the error:

I need to do it programatically because I'm using a menu where I need to be destroying the component container and creating again with the corresponding app component (I'm only using a view for hosting every app, one at time), ComponentContainer doesn't allow to set the usage property more than once. The following are the properties of the parent app in the manifest.json file regarding with component usage.

Thank you very much.

Jhon Jairo.