abstract class sap.ui.core.mvc.View

Control sample: sap.ui.core.mvc.View
Visiblity: public
UX Guidelines:
Implements: sap.ui.core.IDScope
Available since: N/A
Module: sap/ui/core/mvc/View
Application Component: CA-UI5-COR

A base class for Views.

Introduces the relationship to a Controller, some basic visual appearance settings like width and height, and provides lifecycle events.

Views form an ID scope for the elements and controls in their content. They can prefix the IDs of elements either automatically (e.g. XMLView) or programmatically (using #createId). With method #byId, elements or controls can be found with their view-local ID. Also see "Support for Unique IDs" in the documentation.

Note: For Views defined using XML markup On root level, you can only define content for the default aggregation, e.g. without adding the <content> tag. If you want to specify content for another aggregation of a view like dependents, place it in a child control's dependents aggregation or add it by using sap.ui.core.mvc.XMLView.addDependent.

View Definition

A view can be defined by extending this class and implementing the #createContent method. The method must return one or many root controls that will be rendered as content of the view.

Views that are defined that way are referred to as typed views, as each view definition is represented by its own class (type). See Typed Views for further information.

Example: Defining a typed view (module 'myapp/views/MainView.js')

  // view definition
  sap.ui.define([
    "sap/ui/core/mvc/View",
    "sap/m/Panel"
  ], function(View, Panel) {

    return View.extend("myapp.views.MainView", {

      // define, which controller to use
      getControllerName: function() {
        return "myapp.controller.Main";
      },

      // whether the ID of content controls should be prefixed automatically with the view's ID
      getAutoPrefixId: function() {
        return true; // default is false
      }

      // create view content and return the root control(s)
      // or a Promise resolving with the control(s).
      createContent: function() {
        return new Promise(function(res, rej) {
            res(new Panel({...}));
        }).catch(function(err) {
            rej(err);
        });
      }
    });
  });

View Instantiation

The preferred way of instantiating a typed view is via the generic factory View.create.

When the viewName starts with prefix "module:", the remainder of the name is assumed to be the name of a module that exports a typed view (a subclass of View). The module name must use the same syntax as for sap.ui.define/sap.ui.require (slash-separated name without '.js' suffix).

Example: Instantiating a typed view with View.create

  View.create({
    viewName: "module:myapp/views/MainView"
  }).then(oView) {
    oView.placeAt("content");
  });

A typed view can also be instantiated by calling its constructor without any arguments:

  sap.ui.require(["myapp/views/MainView"], function(MainView) {
    new MainView().placeAt("content");
  });

Other Methods

Besides createContent, there are two other methods that a view can implement: Method getControllerName defines the name of the controller that should be instantiated and used for the view. The name must be in class name notation (dot notation), without the ".controller" suffix. The suffix will be added by the framework when loading the module containing the controller.

getAutoPrefixId defines whether the IDs of controls created during the execution of createContent will be prefixed with the ID of the view automatically. The default implementation of this method returns false.


Constructor

Constructor for a new View.

As View is an abstract base class for views, applications should not call the constructor, but rather use one of the view factories instead, e.g. View.create, to create an instance of a concrete subclass (e.g. XMLView).

Accepts an object literal mSettings that defines initial property values, aggregated and associated objects as well as event handlers. See sap.ui.base.ManagedObject#constructor for a general description of the syntax of the settings object.

new sap.ui.core.mvc.View(sId?, mSettings?)
Param Type Default Value Description
sId? string

ID for the new control, generated automatically if no ID is given

mSettings? object

Initial settings for the new control


Properties

Name Type Default Value Description
displayBlock boolean false

Whether the CSS display should be set to "block". Set this to "true" if the default display "inline-block" causes a vertical scrollbar with Views that are set to 100% height. Do not set this to "true" if you want to display other content in the same HTML parent on either side of the View (setting to "true" may push that other content to the next/previous line).

Visibility: public
height sap.ui.core.CSSSize

The height

Visibility: public
viewName string

Name of the View

Visibility: public
width sap.ui.core.CSSSize 100%

The width

Visibility: public

Borrowed Properties

Name Type Default Value Description
blocked boolean false

Whether the control is currently in blocked state.

Visibility: public
busy boolean false

Whether the control is currently in busy state.

Visibility: public
busyIndicatorDelay int 1000

The delay in milliseconds, after which the busy indicator will show up for this control.

Visibility: public
busyIndicatorSize sap.ui.core.BusyIndicatorSize Medium

The size of the BusyIndicator. For controls with a width smaller 3rem a sap.ui.core.BusyIndicatorSize.Small should be used. If the size could vary in width and the width could get smaller than 3rem, the sap.ui.core.BusyIndicatorSize.Auto option could be used. The default is set to sap.ui.core.BusyIndicatorSize.Medium For a full screen BusyIndicator use sap.ui.core.BusyIndicatorSize.Large.

Since: 1.54.

Visibility: public
fieldGroupIds string[]

The IDs of a logical field group that this control belongs to.

All fields in a logical field group should share the same fieldGroupId. Once a logical field group is left, the validateFieldGroup event is fired.

For backward compatibility with older releases, field group IDs are syntactically not limited, but it is suggested to use only valid sap.ui.core.IDs.

See #attachValidateFieldGroup or consult the Field Group documentation.

Since: 1.31.

Visibility: public
visible boolean true

Whether the control should be visible on the screen.

If set to false, a placeholder will be rendered to mark the location of the invisible control in the DOM of the current page. The placeholder will be hidden and have zero dimensions (display: none).

Also see InvisibleRenderer.

Visibility: public

Aggregations

Default Aggregation:

Name Cardinality Type Description
content 0..n sap.ui.core.Control

Child Controls of the view

Borrowed Aggregations

Name Cardinality Type Description
customData 0..n sap.ui.core.CustomData

Custom Data, a data structure like a map containing arbitrary key value pairs.

dependents 0..n sap.ui.core.Element

Dependents are not rendered, but their databinding context and lifecycle are bound to the aggregating Element.

Since: 1.19.

dragDropConfig 0..n sap.ui.core.dnd.DragDropBase

Defines the drag-and-drop configuration. Note: This configuration might be ignored due to control metadata restrictions.

Since: 1.56.

layoutData 0..1 sap.ui.core.LayoutData

Defines the layout constraints for this control when it is used inside a Layout. LayoutData classes are typed classes and must match the embedding Layout. See VariantLayoutData for aggregating multiple alternative LayoutData instances to a single Element.

tooltip 0..1 sap.ui.core.TooltipBase

The tooltip that should be shown for this Element.

In the most simple case, a tooltip is a string that will be rendered by the control and displayed by the browser when the mouse pointer hovers over the control's DOM. In this variant, tooltip behaves like a simple control property.

Controls need to explicitly support this kind of tooltip as they have to render it, but most controls do. Exceptions will be documented for the corresponding controls (e.g. sap.ui.core.HTML does not support tooltips).

Alternatively, tooltip can act like a 0..1 aggregation and can be set to a tooltip control (an instance of a subclass of sap.ui.core.TooltipBase). In that case, the framework will take care of rendering the tooltip control in a popup-like manner. Such a tooltip control can display arbitrary content, not only a string.

UI5 currently does not provide a recommended implementation of TooltipBase as the use of content-rich tooltips is discouraged by the Fiori Design Guidelines. Existing subclasses of TooltipBase therefore have been deprecated. However, apps can still subclass from TooltipBase and create their own implementation when needed (potentially taking the deprecated implementations as a starting point).

See the section Using Tooltips in the Fiori Design Guideline.


Events Overview

Event Description
afterInit

Fired when the View has parsed the UI description and instantiated the contained controls (/control tree).

afterRendering

Fired when the View has been (re-)rendered and its HTML is present in the DOM.

beforeExit

Fired when the view has received the request to destroy itself, but before it has destroyed anything.

beforeRendering

Fired before this View is re-rendered. Use to unbind event handlers from HTML elements etc.

afterInit

Fired when the View has parsed the UI description and instantiated the contained controls (/control tree).

Param Type Description
oControlEvent sap.ui.base.Event
getSource sap.ui.base.EventProvider
getParameters object

afterRendering

Fired when the View has been (re-)rendered and its HTML is present in the DOM.

Param Type Description
oControlEvent sap.ui.base.Event
getSource sap.ui.base.EventProvider
getParameters object

beforeExit

Fired when the view has received the request to destroy itself, but before it has destroyed anything.

Param Type Description
oControlEvent sap.ui.base.Event
getSource sap.ui.base.EventProvider
getParameters object

beforeRendering

Fired before this View is re-rendered. Use to unbind event handlers from HTML elements etc.

Param Type Description
oControlEvent sap.ui.base.Event
getSource sap.ui.base.EventProvider
getParameters object

Methods Overview

Method Description
sap.ui.core.mvc.View._create

Used to bypass the public APIs returning a Promise. Some internal use-cases need the View instance synchronously instead of the wrapping Promises of the [...]View.create() factories: e.g. root-view creation in sap/ui/core/UIComponent Internally, the views might still be loaded and processed asynchronously.

References:

  • {sap.ui.view}

addContent

Adds some content to the aggregation content.

attachAfterInit

Attaches event handler fnFunction to the afterInit event of this sap.ui.core.mvc.View.

When called, the context of the event handler (its this) will be bound to oListener if specified, otherwise it will be bound to this sap.ui.core.mvc.View itself.

Fired when the View has parsed the UI description and instantiated the contained controls (/control tree).

attachAfterRendering

Attaches event handler fnFunction to the afterRendering event of this sap.ui.core.mvc.View.

When called, the context of the event handler (its this) will be bound to oListener if specified, otherwise it will be bound to this sap.ui.core.mvc.View itself.

Fired when the View has been (re-)rendered and its HTML is present in the DOM.

attachBeforeExit

Attaches event handler fnFunction to the beforeExit event of this sap.ui.core.mvc.View.

When called, the context of the event handler (its this) will be bound to oListener if specified, otherwise it will be bound to this sap.ui.core.mvc.View itself.

Fired when the view has received the request to destroy itself, but before it has destroyed anything.

attachBeforeRendering

Attaches event handler fnFunction to the beforeRendering event of this sap.ui.core.mvc.View.

When called, the context of the event handler (its this) will be bound to oListener if specified, otherwise it will be bound to this sap.ui.core.mvc.View itself.

Fired before this View is re-rendered. Use to unbind event handlers from HTML elements etc.

byId

Returns an element by its ID in the context of this view.

This method expects a view-local ID of an element (the same as e.g. defined in the *.view.xml of an XMLView). For a search with a global ID (the value returned by oElement.getId()) you should rather use sap.ui.getCore().byId().

clone

Creates a clone of this view.

Overrides the clone method to avoid conflicts between generic cloning of the content aggregation and content creation as defined by the UI5 Model View Controller lifecycle.

For more details see the View Cloning section in the documentation.

sap.ui.core.mvc.View.create

Creates a view of the given type, name and with the given ID.

If the option viewName is given, the corresponding view module is loaded if needed.

When the viewName starts with prefix "module:", the remainder of the name is assumed to be the name of a module that exports a typed view (subclass of View). The module name must use the same syntax as for sap.ui.define/sap.ui.require (slash-separated name).

createContent

A method to be implemented by typed Views, returning the view UI.

While for declarative view types like XMLView or JSONView the user interface definition is declared in a separate file, Views programmatically constructs the UI. This happens in the createContent method, which every View needs to implement. The view implementation can construct the complete UI in this method, or only return the root control and create the remainder of the UI lazily later on.

createId

Convert the given view local element ID to a globally unique ID by prefixing it with the view ID.

destroyContent

Destroys all the content in the aggregation content.

detachAfterInit

Detaches event handler fnFunction from the afterInit event of this sap.ui.core.mvc.View.

The passed function and listener object must match the ones used for event registration.

detachAfterRendering

Detaches event handler fnFunction from the afterRendering event of this sap.ui.core.mvc.View.

The passed function and listener object must match the ones used for event registration.

detachBeforeExit

Detaches event handler fnFunction from the beforeExit event of this sap.ui.core.mvc.View.

The passed function and listener object must match the ones used for event registration.

detachBeforeRendering

Detaches event handler fnFunction from the beforeRendering event of this sap.ui.core.mvc.View.

The passed function and listener object must match the ones used for event registration.

sap.ui.core.mvc.View.extend

Creates a new subclass of class sap.ui.core.mvc.View 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.core.Control.extend.

fireAfterInit

Fires event afterInit to attached listeners.

fireAfterRendering

Fires event afterRendering to attached listeners.

fireBeforeExit

Fires event beforeExit to attached listeners.

fireBeforeRendering

Fires event beforeRendering to attached listeners.

getAutoPrefixId

A method to be implemented by typed views, returning the flag whether to prefix the IDs of controls automatically or not, if the controls are created inside the sap.ui.core.mvc.View#createContent function. By default this feature is not activated.

You can overwrite this function and return true to activate the automatic prefixing.

Note: Auto-prefixing is only available for synchronous content creation. For asynchronous content creation use #createId instead, to prefix the IDs programmatically.

getContent

Gets content of aggregation content.

Child Controls of the view

getController

Returns the view's Controller instance or null for a controller-less View.

getControllerName

An (optional) method to be implemented by Views. When no controller instance is given at View instantiation time AND this method exists and returns the (package and class) name of a controller, the View tries to load and instantiate the controller and to connect it to itself.

getDisplayBlock

Gets current value of property displayBlock.

Whether the CSS display should be set to "block". Set this to "true" if the default display "inline-block" causes a vertical scrollbar with Views that are set to 100% height. Do not set this to "true" if you want to display other content in the same HTML parent on either side of the View (setting to "true" may push that other content to the next/previous line).

Default value is false.

getHeight

Gets current value of property height.

The height

getLocalId

Returns the local ID of an element by removing the view ID prefix or null if the ID does not contain a prefix.

sap.ui.core.mvc.View.getMetadata

Returns a metadata object for class sap.ui.core.mvc.View.

getPreprocessorInfo

Returns the info object which is also passed to the preprocessors

References:

  • sap.ui.core.mvc.View.Preprocessor.process

getViewData

Returns user specific data object

getViewName

Gets current value of property viewName.

Name of the View

getWidth

Gets current value of property width.

The width

Default value is '100%'.

hasPreprocessor

Checks if any preprocessors are active for the specified type

indexOfContent

Checks for the provided sap.ui.core.Control in the aggregation content. and returns its index if found or -1 otherwise.

insertContent

Inserts a content into the aggregation content.

loaded

Returns a Promise representing the state of the view initialization.

For views that are loading asynchronously (by setting async=true) this Promise is created by view initialization. Synchronously loading views get wrapped in an immediately resolving Promise.

Since 1.66 Use {@link sap.ui.core.mvc.View.create View.create} instead
sap.ui.core.mvc.View.registerPreprocessor

Register a preprocessor for all views of a specific type.

The preprocessor can be registered for several stages of view initialization, which are dependent on the view type, e.g. "raw", "xml" or already initialized "controls". If there is a preprocessor passed to or activated at the view instance already, that one is used. When several preprocessors are registered for one hook, it has to be made sure that they do not conflict when being processed serially.

It can be either a module name as string of an implementation of sap.ui.core.mvc.View.Preprocessor or a function with a signature according to sap.ui.core.mvc.View.Preprocessor.process.

Note: Preprocessors only work in async views and will be ignored when the view is instantiated in sync mode by default, as this could have unexpected side effects. You may override this behaviour by setting the bSyncSupport flag to true.

removeAllContent

Removes all the controls from the aggregation content.

Additionally, it unregisters them from the hosting UIArea.

removeContent

Removes a content from the aggregation content.

runPreprocessor

Executes preprocessors for a type of source

setDisplayBlock

Sets a new value for property displayBlock.

Whether the CSS display should be set to "block". Set this to "true" if the default display "inline-block" causes a vertical scrollbar with Views that are set to 100% height. Do not set this to "true" if you want to display other content in the same HTML parent on either side of the View (setting to "true" may push that other content to the next/previous line).

When called with a value of null or undefined, the default value of the property will be restored.

Default value is false.

setHeight

Sets a new value for property height.

The height

When called with a value of null or undefined, the default value of the property will be restored.

setViewName

Sets a new value for property viewName.

Name of the View

When called with a value of null or undefined, the default value of the property will be restored.

setWidth

Sets a new value for property width.

The width

When called with a value of null or undefined, the default value of the property will be restored.

Default value is '100%'.

sap.ui.core.mvc.View._create

Used to bypass the public APIs returning a Promise. Some internal use-cases need the View instance synchronously instead of the wrapping Promises of the [...]View.create() factories: e.g. root-view creation in sap/ui/core/UIComponent Internally, the views might still be loaded and processed asynchronously.

References:

addContent

Adds some content to the aggregation content.

Param Type DefaultValue Description
oContent sap.ui.core.Control

The content to add; if empty, nothing is inserted

attachAfterInit

Attaches event handler fnFunction to the afterInit event of this sap.ui.core.mvc.View.

When called, the context of the event handler (its this) will be bound to oListener if specified, otherwise it will be bound to this sap.ui.core.mvc.View itself.

Fired when the View has parsed the UI description and instantiated the contained controls (/control tree).

Param Type DefaultValue Description
oData object

An application-specific payload object that will be passed to the event handler along with the event object when firing the event

fnFunction function(sap.ui.base.Event) : void

The function to be called when the event occurs

oListener object

Context object to call the event handler with. Defaults to this sap.ui.core.mvc.View itself

attachAfterRendering

Attaches event handler fnFunction to the afterRendering event of this sap.ui.core.mvc.View.

When called, the context of the event handler (its this) will be bound to oListener if specified, otherwise it will be bound to this sap.ui.core.mvc.View itself.

Fired when the View has been (re-)rendered and its HTML is present in the DOM.

Param Type DefaultValue Description
oData object

An application-specific payload object that will be passed to the event handler along with the event object when firing the event

fnFunction function(sap.ui.base.Event) : void

The function to be called when the event occurs

oListener object

Context object to call the event handler with. Defaults to this sap.ui.core.mvc.View itself

attachBeforeExit

Attaches event handler fnFunction to the beforeExit event of this sap.ui.core.mvc.View.

When called, the context of the event handler (its this) will be bound to oListener if specified, otherwise it will be bound to this sap.ui.core.mvc.View itself.

Fired when the view has received the request to destroy itself, but before it has destroyed anything.

Param Type DefaultValue Description
oData object

An application-specific payload object that will be passed to the event handler along with the event object when firing the event

fnFunction function(sap.ui.base.Event) : void

The function to be called when the event occurs

oListener object

Context object to call the event handler with. Defaults to this sap.ui.core.mvc.View itself

attachBeforeRendering

Attaches event handler fnFunction to the beforeRendering event of this sap.ui.core.mvc.View.

When called, the context of the event handler (its this) will be bound to oListener if specified, otherwise it will be bound to this sap.ui.core.mvc.View itself.

Fired before this View is re-rendered. Use to unbind event handlers from HTML elements etc.

Param Type DefaultValue Description
oData object

An application-specific payload object that will be passed to the event handler along with the event object when firing the event

fnFunction function(sap.ui.base.Event) : void

The function to be called when the event occurs

oListener object

Context object to call the event handler with. Defaults to this sap.ui.core.mvc.View itself

byId

Returns an element by its ID in the context of this view.

This method expects a view-local ID of an element (the same as e.g. defined in the *.view.xml of an XMLView). For a search with a global ID (the value returned by oElement.getId()) you should rather use sap.ui.getCore().byId().

Param Type DefaultValue Description
sId string

View local ID of the element

clone

Creates a clone of this view.

Overrides the clone method to avoid conflicts between generic cloning of the content aggregation and content creation as defined by the UI5 Model View Controller lifecycle.

For more details see the View Cloning section in the documentation.

Param Type DefaultValue Description
sIdSuffix string

Suffix to be appended to the cloned element IDs

aLocalIds string[]

Array of local IDs within the cloned hierarchy (internally used)

sap.ui.core.mvc.View.create

Creates a view of the given type, name and with the given ID.

If the option viewName is given, the corresponding view module is loaded if needed.

When the viewName starts with prefix "module:", the remainder of the name is assumed to be the name of a module that exports a typed view (subclass of View). The module name must use the same syntax as for sap.ui.define/sap.ui.require (slash-separated name).

Param Type DefaultValue Description
oOptions object

Options for the view instantiation. Can contain any settings that are documented for the sap.ui.core.mvc.View; specialized view types could bring in additional settings.

id string

Specifies an ID for the View instance. If no ID is given, one will be generated

viewName string

Name of the view resource in module name notation (dot-separated, without suffix); either viewName or definition must be given. A viewName can be given in the form module:my/views/Main to load a typed view.

definition any

The view definition. Only supported for XML and HTML views. See also sap.ui.core.mvc.XMLView.create and sap.ui.core.mvc.HTMLView.create for more information

type sap.ui.core.mvc.ViewType

Specifies what kind of view will be instantiated. All valid view types are listed in the enumeration sap.ui.core.mvc.ViewType.

viewData any

A general purpose data bag, which is under full control of the caller. It can be retrieved with the sap.ui.core.mvc.View#getViewData method during the whole lifecycle of the view and controller. In contrast to data propagated from the parent control (e.g. models, binding contexts), viewData can already be accessed at construction time, e.g. in the onInit hook of the controller. Propagated data can only be accessed after the view has been added to the control hierarchy.

preprocessors object

Can hold a map from the specified preprocessor type (e.g. "xml") to an array of preprocessor configurations; each configuration consists of a preprocessor property (optional when registered as on-demand preprocessor) and may contain further preprocessor-specific settings. The preprocessor can be either a module name as string implementation of sap.ui.core.mvc.View.Preprocessor or a function according to sap.ui.core.mvc.View.Preprocessor.process. Do not set properties starting with underscore like _sProperty property, these are reserved for internal purposes. When several preprocessors are provided for one hook, it has to be made sure that they do not conflict when being processed serially.

Note: These preprocessors are only available to this instance. For global or on-demand availability use sap.ui.core.mvc.XMLView.registerPreprocessor. Note: Please note that preprocessors in general are currently only available to XMLViews

controller sap.ui.core.mvc.Controller

Controller instance to be used for this view. The given controller instance overrides the controller defined in the view definition. Sharing a controller instance between multiple views is not supported.

createContent

A method to be implemented by typed Views, returning the view UI.

While for declarative view types like XMLView or JSONView the user interface definition is declared in a separate file, Views programmatically constructs the UI. This happens in the createContent method, which every View needs to implement. The view implementation can construct the complete UI in this method, or only return the root control and create the remainder of the UI lazily later on.

createId

Convert the given view local element ID to a globally unique ID by prefixing it with the view ID.

Param Type DefaultValue Description
sId string

View local ID of the element

destroyContent

Destroys all the content in the aggregation content.

detachAfterInit

Detaches event handler fnFunction from the afterInit event of this sap.ui.core.mvc.View.

The passed function and listener object must match the ones used for event registration.

Param Type DefaultValue Description
fnFunction function(sap.ui.base.Event) : void

The function to be called, when the event occurs

oListener object

Context object on which the given function had to be called

detachAfterRendering

Detaches event handler fnFunction from the afterRendering event of this sap.ui.core.mvc.View.

The passed function and listener object must match the ones used for event registration.

Param Type DefaultValue Description
fnFunction function(sap.ui.base.Event) : void

The function to be called, when the event occurs

oListener object

Context object on which the given function had to be called

detachBeforeExit

Detaches event handler fnFunction from the beforeExit event of this sap.ui.core.mvc.View.

The passed function and listener object must match the ones used for event registration.

Param Type DefaultValue Description
fnFunction function(sap.ui.base.Event) : void

The function to be called, when the event occurs

oListener object

Context object on which the given function had to be called

detachBeforeRendering

Detaches event handler fnFunction from the beforeRendering event of this sap.ui.core.mvc.View.

The passed function and listener object must match the ones used for event registration.

Param Type DefaultValue Description
fnFunction function(sap.ui.base.Event) : void

The function to be called, when the event occurs

oListener object

Context object on which the given function had to be called

sap.ui.core.mvc.View.extend

Creates a new subclass of class sap.ui.core.mvc.View 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.core.Control.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

fireAfterInit

Fires event afterInit to attached listeners.

Param Type DefaultValue Description
mParameters object

Parameters to pass along with the event

fireAfterRendering

Fires event afterRendering to attached listeners.

Param Type DefaultValue Description
mParameters object

Parameters to pass along with the event

fireBeforeExit

Fires event beforeExit to attached listeners.

Param Type DefaultValue Description
mParameters object

Parameters to pass along with the event

fireBeforeRendering

Fires event beforeRendering to attached listeners.

Param Type DefaultValue Description
mParameters object

Parameters to pass along with the event

getAutoPrefixId

A method to be implemented by typed views, returning the flag whether to prefix the IDs of controls automatically or not, if the controls are created inside the sap.ui.core.mvc.View#createContent function. By default this feature is not activated.

You can overwrite this function and return true to activate the automatic prefixing.

Note: Auto-prefixing is only available for synchronous content creation. For asynchronous content creation use #createId instead, to prefix the IDs programmatically.

getContent

Gets content of aggregation content.

Child Controls of the view

getController

Returns the view's Controller instance or null for a controller-less View.

getControllerName

An (optional) method to be implemented by Views. When no controller instance is given at View instantiation time AND this method exists and returns the (package and class) name of a controller, the View tries to load and instantiate the controller and to connect it to itself.

getDisplayBlock

Gets current value of property displayBlock.

Whether the CSS display should be set to "block". Set this to "true" if the default display "inline-block" causes a vertical scrollbar with Views that are set to 100% height. Do not set this to "true" if you want to display other content in the same HTML parent on either side of the View (setting to "true" may push that other content to the next/previous line).

Default value is false.

getHeight

Gets current value of property height.

The height

getLocalId

Returns the local ID of an element by removing the view ID prefix or null if the ID does not contain a prefix.

Param Type DefaultValue Description
sId string

Prefixed ID

sap.ui.core.mvc.View.getMetadata

Returns a metadata object for class sap.ui.core.mvc.View.

getPreprocessorInfo

Returns the info object which is also passed to the preprocessors

References:

Param Type DefaultValue Description
bSync boolean

Describes the view execution, true if sync

getViewData

Returns user specific data object

getViewName

Gets current value of property viewName.

Name of the View

getWidth

Gets current value of property width.

The width

Default value is '100%'.

hasPreprocessor

Checks if any preprocessors are active for the specified type

Param Type DefaultValue Description
sType string

Type of the preprocessor, e.g. "raw", "xml" or "controls"

indexOfContent

Checks for the provided sap.ui.core.Control in the aggregation content. and returns its index if found or -1 otherwise.

Param Type DefaultValue Description
oContent sap.ui.core.Control

The content whose index is looked for

insertContent

Inserts a content into the aggregation content.

Param Type DefaultValue Description
oContent sap.ui.core.Control

The content to insert; if empty, nothing is inserted

iIndex int

The 0-based index the content should be inserted at; for a negative value of iIndex, the content is inserted at position 0; for a value greater than the current size of the aggregation, the content is inserted at the last position

loaded

Returns a Promise representing the state of the view initialization.

For views that are loading asynchronously (by setting async=true) this Promise is created by view initialization. Synchronously loading views get wrapped in an immediately resolving Promise.

Since 1.66 Use {@link sap.ui.core.mvc.View.create View.create} instead

sap.ui.core.mvc.View.registerPreprocessor

Register a preprocessor for all views of a specific type.

The preprocessor can be registered for several stages of view initialization, which are dependent on the view type, e.g. "raw", "xml" or already initialized "controls". If there is a preprocessor passed to or activated at the view instance already, that one is used. When several preprocessors are registered for one hook, it has to be made sure that they do not conflict when being processed serially.

It can be either a module name as string of an implementation of sap.ui.core.mvc.View.Preprocessor or a function with a signature according to sap.ui.core.mvc.View.Preprocessor.process.

Note: Preprocessors only work in async views and will be ignored when the view is instantiated in sync mode by default, as this could have unexpected side effects. You may override this behaviour by setting the bSyncSupport flag to true.

Param Type DefaultValue Description
sType string

the type of content to be processed

vPreprocessor string function

module path of the preprocessor implementation or a preprocessor function

sViewType string

type of the calling view, e.g. XML

bSyncSupport boolean

declares if the vPreprocessor ensures safe sync processing. This means the preprocessor will be executed also for sync views. Please be aware that any kind of async processing (like Promises, XHR, etc) may break the view initialization and lead to unexpected results.

bOnDemand boolean

on-demand preprocessor which enables developers to quickly activate the preprocessor for a view, by setting preprocessors : { xml }, for example. This should be false except for very special cases. There can only be one on-demand preprocessor per content type.

mSettings object

optional configuration for preprocessor

removeAllContent

Removes all the controls from the aggregation content.

Additionally, it unregisters them from the hosting UIArea.

removeContent

Removes a content from the aggregation content.

Param Type DefaultValue Description
vContent int string sap.ui.core.Control

The content to remove or its index or id

runPreprocessor

Executes preprocessors for a type of source

Param Type DefaultValue Description
sType string

the type of preprocessor, e.g. "raw", "xml" or "controls"

vSource object string Element

the view source as a JSON object, a raw text, an XML document element or a Promise resolving with those

bSync boolean

describes the view execution, true if sync

setDisplayBlock

Sets a new value for property displayBlock.

Whether the CSS display should be set to "block". Set this to "true" if the default display "inline-block" causes a vertical scrollbar with Views that are set to 100% height. Do not set this to "true" if you want to display other content in the same HTML parent on either side of the View (setting to "true" may push that other content to the next/previous line).

When called with a value of null or undefined, the default value of the property will be restored.

Default value is false.

Param Type DefaultValue Description
bDisplayBlock boolean false

New value for property displayBlock

setHeight

Sets a new value for property height.

The height

When called with a value of null or undefined, the default value of the property will be restored.

Param Type DefaultValue Description
sHeight sap.ui.core.CSSSize

New value for property height

setViewName

Sets a new value for property viewName.

Name of the View

When called with a value of null or undefined, the default value of the property will be restored.

Param Type DefaultValue Description
sViewName string

New value for property viewName

setWidth

Sets a new value for property width.

The width

When called with a value of null or undefined, the default value of the property will be restored.

Default value is '100%'.

Param Type DefaultValue Description
sWidth sap.ui.core.CSSSize '100%'

New value for property width