Show TOC

Model View Controller (MVC)Locate this document in the navigation structure

The Model View Controller (MVC) concept is used in SAPUI5 to separate the representation of information from the user interaction. This separation facilitates development and the changing of parts independently.

Model, view, and controller are assigned the following roles:

  • The view is responsible for defining and rendering the UI.
  • The model manages the application data.
  • The controller reacts to view events and user interaction by modifying the view and model.
A model in the Model View Controller concept holds the data and provides methods to retrieve the data from the database and to set and update data. A controller contains methods that define how model and view interact. The view in the Model View Controller concept is responsible for defining and rendering the UI. SAPUI5 supports predefined view types.

The purpose of data binding in the UI is to separate the definition of the user interface (view), the data visualized by the application (model), and the code for the business logic for processing the data (controller). The separation has the following advantages: It provides better readability, maintainability, and extensibility and it allows you to change the view without touching the underlying business logic and to define several views of the same data.

Views and controllers often form a 1:1 relationship, but it is also possible to have controllers without a UI, these controllers are called application controllers. It is also possible to create views without controllers. From a technical position, a view is a SAPUI5 control and can have or inherit a SAPUI5 model.

View and controller represent reusable units, and distributed development is highly supported.