docs

Component Metadata

The component class provides specific metadata for components by extending the ManagedObject class. The UIComponent class provides additional metadata for the configuration of user interfaces or the navigation between views.

Note:

With the introduction of the descriptor for applications, components, and libraries, we recommend to migrate the component metadata to the descriptor. The descriptor is inspired by W3C’s Web Application Manifest and provides comprehensive information for applications, components and libraries. For more information, see Manifest (Descriptor for Applications, Components, and Libraries). The metadata property manifest must be set to json to indicate that the manifest.json file should be loaded and used:

// "Component" required from module "sap/ui/core/Component"
Component.extend("some.sample.Component", {
    "metadata": {
        "manifest": "json"
    }
});

You can also define the descriptor inline by just providing an object. However, we do not recommend this because this would prevent that the descriptor can be analyzed by tools.

The metadata defined in Component.js is common for components. The following parameters are available:

The following properties are deprecated and no longer needed if you use the descriptor:

Example for metadata in Component.js:

// "Component" required from module "sap/ui/core/Component"
Component.extend("some.sample.Component", {
    "metadata": {
        "manifest": "json", // Specifies that your Component class uses the descriptor via the manifest.json file
        "abstract": true, // Specifies if your Component class is an abstract one that serves as a base for your other components 
        "library": "sap.ui.core", // Specifies the library the component belongs to
        "version": "1.0", // Version of your Component
        "properties": { // Defined for components in the same way as for a control or view
            "config": "any"
        }
    }
});

In addition to the common metadata for components, the UIComponent class provides the following metadata for UI components:

The following properties are deprecated and no longer needed if you use the descriptor:

Example for UI component metadata:

// "UIComponent" required from module "sap/ui/core/UIComponent"
UIComponent.extend("some.sample.UIComponent", {
    "metadata": {
        "publicMethods": [ "render" ],
        "aggregations": {
            "rootControl": {
                "type": "sap.ui.core.Control", multiple: false, visibility: "hidden"
            }
        }
    }
}),

Properties Section in Component Metadata

You can add a properties section to the metadata for all properties that can adopt different values during runtime. The getters and setters for these properties are generated automatically, but you can overwrite them if you require additional functionality. The following example contains two properties at the end of the metadata section.

// "UIComponent" required from module "sap/ui/core/UIComponent"
UIComponent.extend("samples.components.shell.Component", {
    "metadata": {
        "abstract": true,
        "version": "1.0",
...
        "properties": {
            "appTitle": {
                "name":"appTitle",
                "type":"string",
                "defaultValue":"Default Value that will be replaced with something meaningful through the setter for this property"
            },
            "someOtherProp": {
                "name":"myProperty",
                "type":"string",
                "defaultValue":"Some text"
            }
        }
    }
});

The getters and setters for these properties are generated automatically and can be overwritten if additional functionality is required.

Related Information

API Reference: sap.ui.core.Component.MetadataOptions