Show TOC

Methods Controlling the Initial InstantiationLocate this document in the navigation structure

SAPUI5 provides two methods for the initial instantiation of the component.

You can use the following methods:

  • init

    Overwrite this method for example to connect the model between the control and the component. This method is not called by the application directly, but called automatically when you create the instance of the component.

  • createContent

    For UI components, this method returns the component UI as a tree of SAPUI5 controls. Overwrite the method in your component implementation. You use this method to place all the code which is required to fill your component with the respective content, for example, creating an instance of the controls that should be used, or connecting the view that should be displayed. For the latter, you simply need to set this view to the view you want to use. See the following code snippet for an example:

    this.view = sap.ui.view({id:"myView",viewName:"samples.components.products.details.view.Details",type:sap.ui.core.mvc.ViewType.JS});
Note

The configuration properties for a component, that is, the settings given in the constructor or the sap.ui.component call, are not available in the onInit and createContent methods. Use componentData instead. For more information, see sap.ui.component in the API Reference.

You can also overwrite the getters and setters for component properties in the Component.js file.