The developer-guide states "Components are independent and reusable parts used in SAPUI5 applications." but it does not give an example of how to reuse one component in another.
Specifically, I have a component which I want to reuse in different applications. This component has a backing OData-service and a view implementing the UI, and also a controller for encapsulated functions. I have no problems instantiating the component in the applications (which are of course components themselves), but I'm stuck with how I can include the compontent's view in the xml definition of the application. The developer-guide mentions a ComponentContainer as a wrapping control, but I have found no examples on how to use this.
Note that I do know how to reuse fragments or views, but my case seems different since my view is tightly bound to the OData-service (data-binding) of the component.
Any pointer to sample code is highly appriciated. Thanks.
WIth SAPUI5 1.50+ some new feature were introduced allowing you to do the following (usages are declared in the manifest.json):
<core:ComponentContainer
id="compOld"
name="nabi.demo.comp.reuse.northwind.customer.selectionBtn"
async="true"
componentCreated="onComponentCreated"/>
<core:ComponentContainer
id="compNew1"
usage="simpleCustomerSelectionBtn1"
async="true"
componentCreated="onComponentCreated"/>
<core:ComponentContainer
id="compNew2"
usage="simpleCustomerSelectionBtn2"
async="true"
componentCreated="onComponentCreated"/>
For details see here: Implementing Re-use Components in SAPUI5 libraries and consuming them in SAPUI5 apps
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With