0

I'm currently implementing a mockserver for my UI5 Application. Everything works fine, which means my ui5 controls get the mocked data correctly.

The only thing I’m still struggling with are source paths of images.

Here an example: Within an XML Fragment, I have the following image content

<ImageContent src="images/logo_green.svg" press="navToDashboardPage"/>

The Image can be displayed, when I run my normal index.html. When I run the mockserver.html (which in in the test-folder) the path has to be like "../images/logo_green.svg".

How can I set the paths independently from the index.html / mockserver.html? Or is there a way to figure out (within xml) which .html page is currently running?

Thanks for your help :)

MMöller
  • 1
  • 1

2 Answers2

0

Did you try to add a <base href="../"> to your mockserver.html?

A.vH
  • 881
  • 6
  • 10
0

You'll probably need to adapt the data-sap-ui-resourceroots element in the bootstrap. From the UI5 tutorial, this is the invocation in index.html:

<script
        id="sap-ui-bootstrap"
        src="resources/sap-ui-core.js"
        data-sap-ui-resourceroots='{
            "sap.ui.demo.walkthrough": "./"
        }'

and this in test/mockServer.html:

<script
        id="sap-ui-bootstrap"
        src="../resources/sap-ui-core.js"
        data-sap-ui-resourceroots='{
            "sap.ui.demo.walkthrough": "../"
        }'

I don't have an example with an image at the moment but css/styles.css is correctly referenced in both cases, so that should be it.

Also, you should adapt the src path as well, if you're booting from a local copy instead of the CDN. sap.ui.demo.walkthrough of course should be the name of your app.