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:
-
type: The type can be JSON,
JS, XML or HTML.
All possible types are declared in the enumeration
sap.ui.core.mvc.ViewType.
-
viewName: View name corresponding to the module
concept
-
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.
-
Controller: Any controller instance; the given
controller instance overrides the controller defined in the view
definition
-
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.