Skip to content

Commit

Permalink
Merge pull request #112 from boghyon/patch-1
Browse files Browse the repository at this point in the history
Update descriptor-for-applications-components-and-libraries-manifest-json-be0cf40.md
  • Loading branch information
KlattG authored Mar 5, 2024
2 parents 67027c8 + 9158fff commit ebab6fa
Showing 1 changed file with 15 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2885,33 +2885,32 @@ For the following namespaces, the indicated teams are responsible:
The component declares the existence of the application descriptor by specifying `manifest: "json"` in the component metadata. Setting this flag makes the component load the `manifest.json` file and read the relevant entries for SAPUI5. This metadata is used to define the dependencies that need to be loaded in order to start the component. The following code snippet shows how to add the manifest link:
```js
sap.ui.define(['sap/ui/core/UIComponent'], function(UIComponent) {

return UIComponent.extend("sap.samples.Component", {
metadata : {
manifest: "json"
sap.ui.define([
"sap/ui/core/UIComponent"
], (UIComponent) => {
"use strict";
return UIComponent.extend("my.sample.Component", {
metadata: {
manifest: "json",
interfaces: [
"sap.ui.core.IAsyncContentCreation"
]
}
});

});
```
## SAPUI5 API
At runtime, the `manifest.json` content can be accessed from the component via the component metadata:
At runtime, the manifest content can be accessed from the component via the following `sap.ui.core.Component` APIs:
```js
// get the component class
sap.ui.require(['sap/samples/Component'], function(SampleComponent) {

// getting complete manifest from component metadata
SampleComponent.getMetadata().getManifest();
//or getting a namespace
SampleComponent.getMetadata().getManifestEntry("sap.app");

});
// Given: oComponent === instance of sap.ui.core.Component (e.g. returned by sap.ui.core.mvc.Controller#getOwnerComponent).
oComponent.getManifest(); // returns: reference to the entire manifest object if it exists. Otherwise, null.
oComponent.getManifestEntry("sap.app"); // returns: reference to the configuration section of the manifest.
oComponent.getManifestEntry("/sap.ui5/dependencies/libs"); // returns: reference or value of the manifest configuration by path, of which the syntax must start with a slash.
```
[sap.ui.core.UIComponent](https://ui5.sap.com/#/api/sap.ui.core.UIComponent)
Expand Down

0 comments on commit ebab6fa

Please sign in to comment.