Instantiates a view repository that creates and caches views. If it is destroyed, all the Views it created are destroyed. Usually you do not have to create instances of this class, it is used by the sap.ui.core.routing.Router. If you are using sap.ui.core.routing.Targets without using a sap.ui.core.UIComponent you have to create an instance of this class. They will create an instance on their own, or if they are used with a sap.ui.core.UIComponent they will share the same instance of Views.
new sap.ui.core.routing.Views(oOptions?)
Param | Type | Default Value | Description |
---|---|---|---|
oOptions? | object | ||
component? | sap.ui.core.UIComponent | the owner of all the views that will be created by this Instance. |
|
async? | boolean | false | @since 1.34 Whether the views which are created through this Views are loaded asyncly. This option can be set only when the Views is used standalone without the involvement of a Router. Otherwise the async option is inherited from the Router. |
Event | Description |
---|---|
created |
If a view is created, the event will be fired. It will not be fired, if a view was read from the cache of the Views object. |
If a view is created, the event will be fired. It will not be fired, if a view was read from the cache of the Views object.
Param | Type | Description |
---|---|---|
oEvent | sap.ui.base.Event |
refer to sap.ui.base.EventProvider for details about getSource and getParameters |
getSource | sap.ui.base.EventProvider | |
getParameters | object | |
view | sap.ui.core.mvc.View |
the instance of the created view. |
viewOptions | object |
The view options passed to sap.ui.view |
Method | Description |
---|---|
sap.ui.core.routing.Views.extend |
Creates a new subclass of class sap.ui.core.routing.Views with name
|
fireCreated |
Fires event created to attached listeners. |
sap.ui.core.routing.Views.getMetadata |
Returns a metadata object for class sap.ui.core.routing.Views. |
getView |
Returns a cached view, for a given name. If it does not exist yet, it will create the view with the provided options. If you provide a viewId, it will be prefixed with the viewId of the component. |
setView |
Adds or overwrites a view in the cache of the Views instance. The viewName serves as a key for caching. If the second parameter is set to null or undefined, the previous cache view under the same name isn't managed by the Views instance. The lifecycle (for example the destroy of the view) of the view instance should be maintained by additional code. |
Creates a new subclass of class sap.ui.core.routing.Views with name sClassName
and enriches it with the information contained in oClassInfo
.
oClassInfo
might contain the same kind of information as described in sap.ui.base.EventProvider.extend.
Param | Type | DefaultValue | Description |
---|---|---|---|
sClassName | string |
Name of the class being created |
|
oClassInfo | object |
Object literal with information about the class |
|
FNMetaImpl | function |
Constructor function for the metadata object; if not given, it defaults to the metadata implementation used by this class |
Fires event created to attached listeners.
Param | Type | DefaultValue | Description |
---|---|---|---|
oParameters | object |
Parameters to pass along with the event |
Returns a metadata object for class sap.ui.core.routing.Views.
Returns a cached view, for a given name. If it does not exist yet, it will create the view with the provided options. If you provide a viewId, it will be prefixed with the viewId of the component.
Param | Type | DefaultValue | Description |
---|---|---|---|
oOptions | object |
see sap.ui.view for the documentation. The viewId you pass into the options will be prefixed with the id of the component you pass into the constructor. So you can retrieve the view later by calling the sap.ui.core.UIComponent#byId function of the UIComponent. |
|
viewName | string |
If you do not use setView please see sap.ui.view for the documentation. This is used as a key in the cache of the Views instance. If you want to retrieve a view that has been given an alternative name in #setView you need to provide the same name here and you can skip all the other viewOptions. |
Adds or overwrites a view in the cache of the Views instance. The viewName serves as a key for caching.
If the second parameter is set to null or undefined, the previous cache view under the same name isn't managed by the Views instance. The lifecycle (for example the destroy of the view) of the view instance should be maintained by additional code.
Param | Type | DefaultValue | Description |
---|---|---|---|
sViewName | string |
Name of the view, may differ from the actual viewName of the oView parameter provided, since you can retrieve this view per #.getView. |
|
oView | sap.ui.core.mvc.View null undefined |
the view instance |