docs

Components

Components are independent and reusable parts used in OpenUI5 applications.

An application can use components from different locations from where the application is running. Thus, components can be developed by different development teams and be used in different projects. Components also support the encapsulation of closely related parts of an application into a particular component. This makes the structure of an application and its code easier to understand and to maintain.

Note:

Constraints due to cross-origin issues also apply to components.

OpenUI5 provides the following two types of components:

The sap.ui.core.Component class is the base class and provides the metadata for both types of components. To extend the functionality, components can inherit from their base class or from another component.

Components are loaded and created via the component factory function sap.ui.component. You can either pass the name of the component or the URL of the descriptor file (manifest.json) to load it via the descriptor, see Manifest First Function. We recommend loading the component using the descriptor (if available) - it improves performance during the initial load since the loading process can be parallelized and optimized.

After loading the descriptor, the component factory can load the dependencies (OpenUI5 libraries and other dependent components) in parallel next to the component preload, and also models can be preloaded.


Structure of a Component

A component is organized in a unique namespace, the namespace of the component equals the component name.

Basically, a component consists of the component controller (Component.js) and a descriptor (manifest.json). Only the component controller is mandatory, but we recommend to also use the descriptor file. The descriptor then contains the component metadata, and also expresses the component dependencies and configuration (see Manifest (Descriptor for Applications, Components, and Libraries)). All required and optional resources of the component have to be organized in the namespace of the component.

Note:

Optional resources are, for example, CSS, js, or i18n files, views, and controllers.

The following figure gives an example of a component folder structure.

Using Components - Component Tree

The ComponentContainer control wraps a UI component. You use the ComponentContainer control in the OpenUI5 control tree in the same way as any other control.


Differentiation to Other Concepts in OpenUI5

The following list explains how other concepts used in OpenUI5 are distinguished from the OpenUI5 components concept:

Related Information

Manifest (Descriptor for Applications, Components, and Libraries)

API Reference: sap.ui.core.Component