Skip to Content
avatar image
Former Member

Global JS Object in Launchpad

Hello everyone,

in our company we started to deploy some fiori apps into the launchpad. Now we want these apps to share some data and functionality via a global Javascript Object inside the Launchpad. What is the best way to achieve that? Maybe via modules?

We tried it so far the "normal" JS-way: window.myGlobal = ... in the Component.js - file on one of the apps. But the first problem is, the file is only executed, if the app gets started and the second problem is that we can't access the variable in another app. It is undefined, although all apps share the same window object: How to get your SAP UI 5 apps to work like SAP Fiori Apps in SAP Fiori Launchpad.

All ideas are welcome.

Thanks in advance,

Silvio.

Edit: I found out so far, that the apps are executed inside an iframe and so they do not share the same window object.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Best Answer
    avatar image
    Former Member
    Jan 14, 2015 at 09:22 AM


    Hi Silvio,

    The recommended way to communicate between components/apps is via the eventbus, general best practices in js is to avoid global variables as they become increasingly tough to maintain as your application grows.

    Please find more info on eventbus

    Step 3: Navigation and Routing

    Thank you.

    Regards,

                   Pruthvi.

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hello Pruthvi,

      you're absolutly right in general. But in our scenario it is necessary that the apps share data on client side, because sometimes the state of one app depends on the state of another app.

      The solution in our case was to deploy the app as components, not as standalone apps inside launchpad via the index.html. The problem is, although Component.js and index.html share the same folder at development time they are in different folders on runtime. So we had to find the right path. It is a bit confusing, but here the concret example:

      Works: <host:port>/sap/bc/bsp/sap/myapp/index.html

      Works NOT: <host:port>/sap/bc/bsp/sap/myapp/Component.js

      Works: <host:port>/sap/bc/ui5_ui5/sap/myapp/Component.js


      So now the app no longer running as iframes inside the launchpad and share the same window object.


      Problem solved.


      Greetings,


      Silvio.