Show TOC

Instantiating ViewsLocate this document in the navigation structure

To instantiate views, SAPUI5 provides the factory method sap.ui.view.

Procedure

To pass required information for the instantiation, use an object with the following properties:
  1. type: The type can be JSON, JS, XML or HTML. All possible types are declared in the enumeration sap.ui.core.mvc.ViewType.
  2. viewName: View name corresponding to the module concept
  3. viewContent: Only relevant for XML views and JSON views. Defines the XML or JSON string representation of the view definition. If viewName and viewContent are given, the viewName property is used to load the view definition.
  4. Controller: Any controller instance; the given controller instance overrides the controller defined in the view definition
  5. viewData: Only used for JS views; this property contains user-specific data that is available during the whole lifecycle of the view and the controller
...
   var myController = sap.ui.controller("my.own.controller");
   var myView = sap.ui.view({ type: sap.ui.core.mvc.ViewType.XML,
                              viewName: "my.own.view",
                              controller: myController 
                            });
...

All regular properties of a view (control) can be passed to the object as usual.