2

I am using the OpenUI5 framework to create a custom component. I want to access some config settings that I set in the component's manifest.json file. According to the documentation I can create some name/value pairs within a "config" object nested inside the "sap.ui5" object:

config: Static configuration; specify the name-value pairs that you need in your component.

and i should be able to access those settings from my component like so:

this.getMetadata().getManifest();

After calling that method and inspecting the returned sap.ui5 object in the console, the only objects available are "dependencies", "extends", "models", and "rootView". No "config" object.

How can i access my config settings in the manifest.json?

snippet of manifest.json:

...
"sap.ui5": {
    "_version": "1.1.0",
    "rootView": {
        "viewName": "ctg.openui5.components.webmap.view.Map",
        "type": "HTML"
    },
    "dependencies": {
        "minUI5Version": "1.30",
        "libs": {
            "sap.m": {}
        }
    },
    "models": {
        "i18n": {
            "type": "sap.ui.model.resource.ResourceModel",
            "settings": {
                "bundleName": "ctg.openui5.components.webmap.i18n.i18n"
            }
        }
    },
    "config": {
        "lat": 1,
        "lon": 2
    }
}
hirse
  • 2,394
  • 1
  • 22
  • 24
user1025184
  • 57
  • 3
  • 7
  • I made a minimum example where it works. What UI5 version are you using? Where are you calling `getManifest`? – Marc Mar 03 '16 at 07:16
  • @Marc: I am using the CDN version of UI5. Not sure what I was doing wrong previously, but calling this.getMetadata().getManifest() (where 'this' is the component) is now returning an object with a 'config' object nested inside the sap.ui5 object. – user1025184 Mar 03 '16 at 17:08

1 Answers1

4

Based on the documentation, you can use

this.getManifestEntry("/sap.ui5/config");

in you Component to get the config object in your Manifest.

hirse
  • 2,394
  • 1
  • 22
  • 24
  • Thank for this informative post. Is there such a thing we can change a value in manifest.json, also? Something like this.setMainfestEntry("/sap.ui5/config/lat", 2); ??? – Merve Gül Feb 05 '21 at 05:54