Skip to Content
avatar image
Former Member

Reusing Components in SAPUI5 when using SAP Web IDE

Hi Experts,

though I basically read everything I could find about the components in SAPUI5 I still struggle with the understanding of the whole concept especially how this works in SAP Web IDE or on HCP.

Let's assume we have 2 projects (A and B) in SAP Web IDE.

  • "A" is a standalone application - Type "application" in the manifest.json

  • "B" is just a component - Type "component" in the manifest.json

I simply want to make use of component "B" within application "A". Let's assume application "A" has a certain field with a value help and component "B" is a custom view with some logic that should be shown in the value help dialog of the field.

It's clear to me that I have to load component "B" within the controller S1 in component "A" where I want to use it. As far as I understand that can either be done explicitly using sap.ui.require or implicitly by loading it in the dependency array within the sap.ui.define Statement of controller S1. I have done the latter in my application. What I don't understand is how application "A" can ever load component "B" since it's just another project in my SAP Web IDE and it's fully unknown to application "A". In every case I got an error that loading of component "B" failed.

To overcome this I tried to deploy component "B" to the HCP. I was not successful with and got a meaningless error message: "Cannot build application". I noticed that it works fine if I change the type of component "B" in the manifest.json to "application" instead of "component".

From now on (since application "B" is deployed to HCP) I was able to access it from application "A" when I added the following dependancy in the component controller of application "A" at the very beginning:

jQuery.sap.registerModulePath("B", "../../../../../B");

Though everything works fine now, I have the gut feeling I have chosen the wrong approach by declaring "B" as an application, deploying it to HCP and registering it using the code above.

Maybe someone can shed some light into this. How can I actually declare "B" as an component and reuse it in other applications if components cannot be deployed to HCP?

Regards

Tobias

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • avatar image
    Former Member
    Dec 09, 2016 at 08:30 AM

    Nobody out there who ever tried to reuse a component in SAP Web IDE?

    Add comment
    10|10000 characters needed characters exceeded