cancel
Showing results for 
Search instead for 
Did you mean: 

SAPUI5 : Loading files from different UI5 repository not working

Badhusha
Participant
0 Kudos

I have a UI5 application which will use views and controllers, from another UI5 repo. To achieve this I have created 2 apps ( UI5 repo ) as

  • commonui ( This is not an actual app, but it is just a provider, which have reusable views & controllers
  • mainappui - This has its own views and controllers, and uses the BaseController.js from the commonui, and other views too

The code looks like below

index.html of commonui

sap.ui.define(
    ["sap/ui/core/mvc/Controller", "sap/ui/core/routing/History", "sap/ui/core/UIComponent"],
    function (Controller, History, UIComponent) {
        "use strict";

        return Controller.extend("com.testapp.commonui.controller.BaseController", {
            formatter: formatter,
            getModel: function (sName) {
                return this.getView().getModel(sName);
            },
})

xs-app.json of commonui

  "welcomeFile": "/index.html",
  "authenticationMethod": "route",
  "logout": {
    "logoutEndpoint": "/do/logout"
  },
  "routes": [
    {
      "source": "^(.*)$",
      "target": "$1",
      "service": "html5-apps-repo-rt",
      "authenticationType": "xsuaa"
    }
  ]
}
index.html of mainappui
//
..... Showing only the resourceroots
data-sap-ui-resourceroots='{
            "com.testapp.mainappui": "./",
            "com.testapp.commonui.": "./../comtestappcommonui./"<br>        }'
//......

mta.yaml

ID: lastmile
_schema-version: 3.2.0
version: 0.0.1
parameters:
  enable-parallel-deployments: true
modules:
  - name: webapp_deployer
    type: com.sap.application.content
    path: deployer
    requires:
      - name: main_html5_repo_host
        parameters:
          content-target: true
    build-parameters:
      build-result: resources
      requires:
        - name: commonui
          artifacts:
            - dist/commonui.zip
          target-path: resources/
        - name: mainappui
          artifacts:
            - dist/mainappui.zip
          target-path: resources/

  - name: commonui
    type: html5
    path: commonui
    build-parameters:
      builder: custom
      commands:
        - npm run build:commonui --prefix ..
      supported-platforms: []

  - name: mainappui
    type: html5
    path: mainappui
    build-parameters:
      builder: custom
      commands:
        - npm run build:mainappui --prefix ..<br>      supported-platforms: []


resources:
  - name: main_html5_repo_host
    type: org.cloudfoundry.managed-service
    parameters:
      service-plan: app-host
      service: html5-apps-repo

When I launch the app, the mainappui is fetching the BaseController.js from different URL/Domain

Please let me know what is wrong here

View Entire Topic
Marian_Zeis
Active Contributor

It seems that resourceRoots does not work here.

Try setting it in the manifest.json like:

"resourceRoots": {
    "com.testapp.commonui": "USEYOURPATHHERE"
},
Badhusha
Participant
0 Kudos

Thank You 20eed143c19f4b82bc4cf049916102cb , it worked.

In my case it was

"resourceRoots": {
    "com.testapp.commonui": "../../comtestappcommonui/"
}