Class sap.ui.base.ManagedObjectModule: sap/ui/base/ManagedObject
Base Class that introduces some basic concepts like state management or databinding.
New subclasses of ManagedObject are created with a call to ManagedObject.extend and can make use of the following managed features:
Properties
Managed properties represent the state of a ManagedObject. They can store a single value of a simple data type (like 'string' or 'int'). They have a name (e.g. 'size') and methods to get the current value (getSize
) or to set a new value (setSize
). When a property is modified, the ManagedObject is marked as invalidated. A managed property can be bound against a property in a sap.ui.model.Model by using the bindProperty method. Updates to the model property will be automatically reflected in the managed property and - if TwoWay databinding is active, changes to the managed property will be reflected in the model. An existing binding can be removed by calling unbindProperty.
If a ManagedObject is cloned, the clone will have the same values for its managed properties as the source of the clone - if the property wasn't bound. If it is bound, the property in the clone will be bound to the same model property as in the source.
Details about the declaration of a managed property, the metadata that describes it and the set of methods that are automatically generated to access it, can be found in the documentation of the extend method.
Aggregations
Managed aggregations can store one or more references to other ManagedObjects. They are a mean to control the lifecycle of the aggregated objects: one ManagedObject can be aggregated by at most one parent ManagedObject at any time. When a ManagedObject is destroyed, all aggregated objects are destroyed as well and the object itself is removed from its parent. That is, aggregations won't contain destroyed objects or null/undefined.
Aggregations have a name ('e.g 'header' or 'items'), a cardinality ('0..1' or '0..n') and are of a specific type (which must be a subclass of ManagedObject as well or a UI5 interface). A ManagedObject will provide methods to set or get the aggregated object for a specific aggregation of cardinality 0..1 (e.g. setHeader
, getHeader
for an aggregation named 'header'). For an aggregation of cardinality 0..n, there are methods to get all aggregated objects (getItems
), to locate an object in the aggregation (e.g. indexOfItem
), to add, insert or remove a single aggregated object (addItem
, insertItem
, removeItem
) or to remove or destroy all objects from an aggregation (removeAllItems
, destroyItems
).
Details about the declaration of a managed aggregation, the metadata that describes it and the set of methods that are automatically generated to access it, can be found in the documentation of the extend method.
Aggregations of cardinality 0..n can be bound to a collection in a model by using bindAggregation (and unbound again using unbindAggregation. For each context in the model collection, a corresponding object will be created in the managed aggregation, either by cloning a template object or by calling a factory function.
Aggregations also control the databinding context of bound objects: by default, aggregated objects inherit all models and binding contexts from their parent object.
When a ManagedObject is cloned, all aggregated objects will be cloned as well - but only if they haven't been added by databinding. In that case, the aggregation in the clone will be bound to the same model collection.
Associations
Managed associations also form a relationship between objects, but they don't define a lifecycle for the associated objects. They even can 'break' in the sense that an associated object might have been destroyed already although it is still referenced in an association. For the same reason, the internal storage for associations are not direct object references but only the IDs of the associated target objects.
Associations have a name ('e.g 'initialFocus'), a cardinality ('0..1' or '0..n') and are of a specific type (which must be a subclass of ManagedObject as well or a UI5 interface). A ManagedObject will provide methods to set or get the associated object for a specific association of cardinality 0..1 (e.g. setInitialFocus
, getInitialFocus
). For an association of cardinality 0..n, there are methods to get all associated objects (getRefItems
), to add, insert or remove a single associated object (addRefItem
, insertRefItem
, removeRefItem
) or to remove all objects from an association (removeAllRefItems
).
Details about the declaration of a managed association, the metadata that describes it and the set of methods that are automatically generated to access it, can be found in the documentation of the extend method.
Associations can't be bound to the model.
When a ManagedObject is cloned, the result for an association depends on the relationship between the associated target object and the root of the clone operation: if the associated object is part of the to-be-cloned object tree (reachable via aggregations from the root of the clone operation), then the cloned association will reference the clone of the associated object. Otherwise it will reference the same object as in the original tree. When a ManagedObject is destroyed, other objects that are only associated, are not affected by the destroy operation.
Events
Managed events provide a mean for communicating important state changes to an arbitrary number of 'interested' listeners. Events have a name and (optionally) a set of parameters. For each event there will be methods to add or remove an event listener as well as a method to fire the event. (e.g. attachChange
, detachChange
, fireChange
for an event named 'change').
Details about the declaration of a managed events, the metadata that describes it and the set of methods that are automatically generated to access it, can be found in the documentation of the extend method.
When a ManagedObject is cloned, all listeners registered for any event in the clone source are also registered to the clone. Later changes are not reflect in any direction (neither from source to clone nor vice versa).
Low Level APIs:
The prototype of ManagedObject provides several generic, low level APIs to manage properties, aggregations, associations and events. These generic methods are solely intended for implementing higher level, non-generic methods that manage a single managed property etc. (e.g. a function setSize(value)
that sets a new value for property 'size'). sap.ui.base.ManagedObject.extend creates default implementations of those higher level APIs for all managed aspects. The implementation of a subclass then can override those default implementations with a more specific implementation, e.g. to implement a side effect when a specific property is set or retrieved. It is therefore important to understand that the generic low-level methods ARE NOT SUITABLE FOR GENERIC ACCESS to the state of a managed object, as that would bypass the overriding higher level methods and their side effects.
Experimental API:Since 1.11.2. ManagedObject as such is public and usable. Only the support for the optional parameter oScope in the constructor is still experimental and might change in future versions. Applications should not rely on it.
sId
and settings.sClassName
and enriches it with the information contained in oClassInfo
.oObject
to the aggregation identified by sAggregationName
.sId
to the association identified by sAssociationName
and marks this ManagedObject as changed.mSettings
.fnFunction
to the formatError
event of this sap.ui.base.ManagedObject
.fnFunction
to the modelContextChange
event of this sap.ui.base.ManagedObject
.fnFunction
to the parseError
event of this sap.ui.base.ManagedObject
.fnFunction
to the validationError
event of this sap.ui.base.ManagedObject
.fnFunction
to the validationSuccess
event of this sap.ui.base.ManagedObject
.sAggregationName
and empties the aggregation.fnFunction
from the formatError
event of this sap.ui.base.ManagedObject
.fnFunction
from the modelContextChange
event of this sap.ui.base.ManagedObject
.fnFunction
from the parseError
event of this sap.ui.base.ManagedObject
.fnFunction
from the validationError
event of this sap.ui.base.ManagedObject
.fnFunction
from the validationSuccess
event of this sap.ui.base.ManagedObject
.null
if this object hasn't been added to a parent yet.null
if this object hasn't been added to a parent yet.oObject
to the aggregation named sAggregationName
at position iIndex
.sAggregationName
with cardinality 0.sAssociationName
.sId
and settings. If the optional mSettings
are given, they must be a simple object that defines values for properties, aggregations, associations or events keyed by their name.
Valid Names and Value Ranges:
The property (key) names supported in the object literal are exactly the (case sensitive) names documented in the JSDoc for the properties, aggregations, associations and events of the current class and its base classes. Note that for 0..n aggregations and associations this name usually is the plural name, whereas it is the singular name in case of 0..1 relations.
If a key name is ambiguous for a specific managed object class (e.g. a property has the same name as an event), then this method prefers property, aggregation, association and event in that order. To resolve such ambiguities, the keys can be prefixed with aggregation:
, association:
or event:
(such keys containing a colon (':') must be quoted to be valid Javascript).
The possible values for a setting depend on its kind:
- for simple properties, the value has to match the documented type of the property (no type conversion occurs)
- for 0..1 aggregations, the value has to be an instance of the aggregated type
- for 0..n aggregations, the value has to be an array of instances of the aggregated type or a single instance
- for 0..1 associations, an instance of the associated type or an id (string) is accepted
- for 0..n associations, an array of instances of the associated type or of Ids is accepted
- for events either a function (event handler) is accepted or an array of length 2 where the first element is a function and the 2nd element is an object to invoke the method on.
Each subclass should document the name and type of its supported settings in its constructor documentation.
Besides the settings documented below, ManagedObject itself supports the following special settings:
id : sap.ui.core.ID
an ID for the new instance. Some subclasses (Element, Component) require the id to be unique in a specific scope (e.g. an Element Id must be unique across all Elements, a Component id must be unique across all Components).models : object
a map of sap.ui.model.Model instances keyed by their model name (alias). Each entry with key k in this object has the same effect as a callthis.setModel(models[k], k);
.bindingContexts : object
a map of sap.ui.model.Context instances keyed by their model name. Each entry with key k in this object has the same effect as a callthis.setBindingContext(bindingContexts[k], k);
objectBindings : object
a map of binding paths keyed by the corresponding model name. Each entry with key k in this object has the same effect as a callthis.bindObject(objectBindings[k], k);
The supported settings are:
- Events
- validationSuccess : fnListenerFunction or [fnListenerFunction, oListenerObject] or [oData, fnListenerFunction, oListenerObject]
- validationError : fnListenerFunction or [fnListenerFunction, oListenerObject] or [oData, fnListenerFunction, oListenerObject]
- parseError : fnListenerFunction or [fnListenerFunction, oListenerObject] or [oData, fnListenerFunction, oListenerObject]
- formatError : fnListenerFunction or [fnListenerFunction, oListenerObject] or [oData, fnListenerFunction, oListenerObject]
- modelContextChange : fnListenerFunction or [fnListenerFunction, oListenerObject] or [oData, fnListenerFunction, oListenerObject]
{string} | sId? | id for the new managed object; generated automatically if no non-empty id is given Note: this can be omitted, no matter whether mSettings will be given or not! |
{object} | mSettings? | Optional map/JSON-object with initial property values, aggregated objects etc. for the new object |
{object} | oScope? | Scope object for resolving string based type and formatter references in bindings. When a scope object is given, mSettings cannot be omitted, at least null or an empty object literal must be given. |
{sap.ui.base.Event} | oControlEvent | |
{sap.ui.base.EventProvider} | oControlEvent.getSource | |
{object} | oControlEvent.getParameters | |
{sap.ui.base.ManagedObject} | oControlEvent.getParameters.element | ManagedObject instance whose property should have received the model update. |
{string} | oControlEvent.getParameters.property | Name of the property for which the binding should have been updated. |
{sap.ui.model.Type} | oControlEvent.getParameters.type | Data type used in the binding (if any). |
{any} | oControlEvent.getParameters.newValue | New value (model representation) as propagated from the model. |
{any} | oControlEvent.getParameters.oldValue | Old value (external representation) as previously stored in the ManagedObject. |
{sap.ui.base.Event} | oControlEvent | |
{sap.ui.base.EventProvider} | oControlEvent.getSource | |
{object} | oControlEvent.getParameters |
{sap.ui.base.Event} | oControlEvent | |
{sap.ui.base.EventProvider} | oControlEvent.getSource | |
{object} | oControlEvent.getParameters | |
{sap.ui.base.ManagedObject} | oControlEvent.getParameters.element | ManagedObject instance whose property initiated the model update. |
{string} | oControlEvent.getParameters.property | Name of the property for which the bound model property should have been been updated. |
{sap.ui.model.Type} | oControlEvent.getParameters.type | Data type used in the binding. |
{any} | oControlEvent.getParameters.newValue | New value (external representation) as parsed by the binding. |
{any} | oControlEvent.getParameters.oldValue | Old value (external representation) as previously stored in the ManagedObject. |
{string} | oControlEvent.getParameters.message | Localized message describing the parse error |
{sap.ui.base.Event} | oControlEvent | |
{sap.ui.base.EventProvider} | oControlEvent.getSource | |
{object} | oControlEvent.getParameters | |
{sap.ui.base.ManagedObject} | oControlEvent.getParameters.element | ManagedObject instance whose property initiated the model update. |
{string} | oControlEvent.getParameters.property | Name of the property for which the bound model property should have been been updated. |
{sap.ui.model.Type} | oControlEvent.getParameters.type | Data type used in the binding. |
{any} | oControlEvent.getParameters.newValue | New value (external representation) as parsed and validated by the binding. |
{any} | oControlEvent.getParameters.oldValue | Old value (external representation) as previously stored in the ManagedObject. |
{string} | oControlEvent.getParameters.message | Localized message describing the validation issues |
{sap.ui.base.Event} | oControlEvent | |
{sap.ui.base.EventProvider} | oControlEvent.getSource | |
{object} | oControlEvent.getParameters | |
{sap.ui.base.ManagedObject} | oControlEvent.getParameters.element | ManagedObject instance whose property initiated the model update. |
{string} | oControlEvent.getParameters.property | Name of the property for which the bound model property has been updated. |
{sap.ui.model.Type} | oControlEvent.getParameters.type | Data type used in the binding. |
{any} | oControlEvent.getParameters.newValue | New value (external representation) as propagated to the model. Note: the model might modify (normalize) the value again and this modification will be stored in the ManagedObject. The 'newValue' parameter of this event contains the value before such a normalization. |
{any} | oControlEvent.getParameters.oldValue | Old value (external representation) as previously stored in the ManagedObject. |
If vData is a managed object already, that object is returned. If vData is an object (literal), then a new object is created with vData as settings. The type of the object is either determined by a "Type" entry in the vData or by a type information in the oKeyInfo object
{sap.ui.base.ManagedObject|object} | vData | the data to create the object from |
{object} | oKeyInfo | |
{object} | oScope? | Scope object to resolve types and formatters in bindings |
sClassName
and enriches it with the information contained in oClassInfo
. oClassInfo
can contain the same information that sap.ui.base.Object.extend already accepts, plus the following new properties in the 'metadata' object literal:
library : string
properties : object
aggregations : object
defaultAggregation : string
associations : object
events : object
specialSettings : object
// this one is still experimental and not for public usage!
Each of these properties is explained in more detail lateron.
Example:
ManagedObect.extend('sap.mylib.MyClass', { metadata : { library: 'sap.mylib', properties : { width: 'sap.ui.core.CSSSize', height: { type: 'sap.ui.core.CSSSize', defaultValue: '100%' } }, aggregations : { header : { type: 'sap.mylib.FancyHeader', multiple : false } items : 'sap.ui.core.Control' }, defaultAggregation : 'items', associations : { initiallyFocused : { type: 'sap.ui.core.Control' } }, events: { beforeOpen : { parameters : { opener : 'sap.ui.core.Control' } } }, }, init: function() { } }); // end of 'extend' call
Detailed explanation of properties
'library' : string
Name of the library that the new subclass should belong to. If the subclass is a control or element, it will automatically register with that library so that authoring tools can discover it. By convention, the name of the subclass should have the library name as a prefix, e.g. 'sap.ui.commons.Panel' belongs to library 'sap.ui.commons'.
'properties' : object
An object literal whose properties each define a new managed property in the ManagedObject subclass. The value can either be a simple string which then will be assumed to be the type of the new property or it can be an object literal with the following properties
type: string
type of the new property. Must either be one of the built-in types 'string', 'boolean', 'int', 'float', 'object' or 'any', or a type created and registered with sap.ui.base.DataType.createType or an array type based on one of the previous types.group: ...
defaultValue: any
the default value for the property or null if there is no defaultValue.bindable: boolean|string
(either can be omitted or set to the boolean valuetrue
or the magic string 'bindable') If set totrue
or 'bindable', additional named methodsbindName
andunbindName
are generated as convenience. Despite its name, setting this flag is not mandatory to make the managed property bindable. The generic methods bindProperty and unbindProperty can always be used.
For each public property 'foo', the following methods will be created by the "extend" method and will be added to the prototype of the subclass:
- getFoo() - returns the current value of property 'foo'. Internally calls getProperty
- setFoo(v) - sets 'v' as the new value of property 'foo'. Internally calls setProperty
- bindFoo(c) - (only if property was defined to be 'bindable'): convenience function that wraps bindProperty
- unbindFoo() - (only if property was defined to be 'bindable'): convenience function that wraps unbindProperty
'aggregations' : object
An object literal whose properties each define a new aggregation in the ManagedObject subclass. The value can either be a simple string which then will be assumed to be the type of the new aggregation or it can be an object literal with the following properties
type: string
type of the new aggregation. must be the full global name of a ManagedObject subclass (in dot notation, e.g. 'sap.m.Button')[multiple]: boolean
whether the aggregation is a 0..1 (false) or a 0..n aggregation (true), defaults to true[singularName]: string
. Singular name for 0..n aggregations. For 0..n aggregations the name by convention should be the plural name. Methods affecting multiple objects in an aggregation will use the plural name (e.g. getItems(), whereas methods that deal with a single object will use the singular name (e.g. addItem). The framework knows a set of common rules for building plural form of English nouns and uses these rules to determine a singular name on its own. if that name is wrong, a singluarName can be specified with this property.- [visibility]: string either 'hidden' or 'public', defaults to 'public'. Aggregations that belong to the API of a class must be 'public' whereas 'hidden' aggregations typically are used for the implementation of composite classes (e.g. composite controls)
bindable: boolean|string
(either can be omitted or set to the boolean valuetrue
or the magic string 'bindable') If set totrue
or 'bindable', additional named methodsbindName
andunbindName
are generated as convenience. Despite its name, setting this flag is not mandatory to make the managed aggregation bindable. The generic methods bindAggregation and unbindAggregation can always be used.
For each public aggregation 'item' of cardinality 0..1, the following methods will be created by the "extend" method and will be added to the prototype of the subclass:
- getItem() - returns the current value of aggregation 'item'. Internally calls getAggregation with a default value of
undefined
- setItem(o) - sets 'o' as the new aggregated object in aggregation 'item'. Internally calls setAggregation
- destroyItem(o) - destroy a currently aggregated object in aggregation 'item' and clears the aggregation. Internally calls destroyAggregation
- bindItem(c) - (only if aggregation was defined to be 'bindable'): convenience function that wraps bindAggregation
- unbindItem() - (only if aggregation was defined to be 'bindable'): convenience function that wraps unbindAggregation
- getItems() - returns an array with the objects contained in aggregation 'items'. Internally calls getAggregation with a default value of
[]
- addItem(o) - adds an object as last element in the aggregation 'items'. Internally calls addAggregation
- insertItem(o,p) - inserts an object into the aggregation 'items'. Internally calls insertAggregation
- removeItem(v) - removes an object from the aggregation 'items'. Internally calls removeAggregation
- removeItems() - removes all object from the aggregation 'items'. Internally calls removeAllAggregation
- destroyItems() - destroy all currently aggregated objects in aggregation 'items' and clears the aggregation. Internally calls destroyAggregation
- bindItems(c) - (only if aggregation was defined to be 'bindable'): convenience function that wraps bindAggregation
- unbindItems() - (only if aggregation was defined to be 'bindable'): convenience function that wraps unbindAggregation
'defaultAggregation' : string
When specified, the default aggregation must match the name of one of the aggregations defined for the new subclass (either own or inherited). The named aggregation will be used in contexts where no aggregation is specified. E,g. when an object in an XMLView embeds other objects without naming an aggregation, as in the following example:
<!-- assuming the defaultAggregation for Dialog is 'content' --> <Dialog> <Text/> <Button/> </Dialog>
'associations' : object
An object literal whose properties each define a new association of the ManagedObject subclass. The value can either be a simple string which then will be assumed to be the type of the new association or it can be an object literal with the following properties
type: string
type of the new associationmultiple: boolean
whether the association is a 0..1 (false) or a 0..n association (true), defaults to false(1) for associations[singularName]: string
. Singular name for 0..n associations. For 0..n associations the name by convention should be the plural name. Methods affecting multiple objects in an association will use the plural name (e.g. getItems(), whereas methods that deal with a single object will use the singular name (e.g. addItem). The framework knows a set of common rules for building plural form of English nouns and uses these rules to determine a singular name on its own. if that name is wrong, a singluarName can be specified with this property.
For each association 'ref' of cardinality 0..1, the following methods will be created by the "extend" method and will be added to the prototype of the subclass:
- getRef() - returns the current value of association 'item'. Internally calls getAssociation with a default value of
undefined
- setRef(o) - sets 'o' as the new associated object in association 'item'. Internally calls setAssociation
- getRefs() - returns an array with the objects contained in association 'items'. Internally calls getAssociation with a default value of
[]
- addRef(o) - adds an object as last element in the association 'items'. Internally calls addAssociation
- removeRef(v) - removes an object from the association 'items'. Internally calls removeAssociation
- removeAllRefs() - removes all objects from the association 'items'. Internally calls removeAllAssociation
'events' : object
An object literal whose properties each define a new event of the ManagedObject subclass. The value can either be a simple string which then will be assumed to be the type of the new association or it can be an object literal with the following properties
allowPreventDefault: boolean
whether the event allows to prevented the default behavior of the event sourceparameters: object
an object literal that describes the parameters of this event.
For each event 'Some' the following methods will be created by the "extend" method and will be added to the prototype of the subclass:
- attachSome(fn,o) - registers a listener for the event. Internally calls attachEvent
- detachSome(fn,o) - deregisters a listener for the event. Internally calls detachEvent
- fireSome() - fire the event. Internally calls fireEvent
'specialSettings' : object
Special settings are an experimental feature and MUST NOT BE USED by controls or applications outside of the sap.ui.core project.
Experimental API:Since 1.27.0 Support for 'specialSettings' is experimental and might be modified or removed in future versions. They must not be used in any way outside of the sap.ui.core library. Code outside sap.ui.core must not declare special settings nor must it try to retrieve / evaluate metadata for such settings.
{string} | sClassName | name of the class to be created |
{object} | oClassInfo? | object literal with informations about the class |
{function} | FNMetaImpl? | constructor function for the metadata object. If not given, it defaults to sap.ui.core.ManagedObjectMetadata. |
- Experimental:
- Since 1.27.0 Support for 'specialSettings' is experimental and might be modified or removed in future versions. They must not be used in any way outside of the sap.ui.core library. Code outside sap.ui.core must not declare special settings nor must it try to retrieve / evaluate metadata for such settings.
{function} | the created class / constructor function |
{sap.ui.base.ManagedObjectMetadata} | Metadata for the ManagedObject class. |
oObject
to the aggregation identified by sAggregationName
. If the given object is not valid with regard to the aggregation (if it is not an instance of the type specified for that aggregation) or when the method is called for an aggregation of cardinality 0..1, then an Error is thrown (see validateAggregation.
If the aggregation already has content, the new object will be added after the current content. If the new object was already contained in the aggregation, it will be moved to the end.
Note: This method is a low-level API as described in the class documentation. Applications or frameworks must not use this method to generically add an object to an aggregation. Use the concrete method addXYZ for aggregation 'XYZ' or the generic applySettings instead.
{string} | sAggregationName | the string identifying the aggregation that oObject should be added to. |
{sap.ui.base.ManagedObject} | oObject | the object to add; if empty, nothing is added |
{boolean} | bSuppressInvalidate? | if true, this ManagedObject as well as the added child are not marked as changed |
{sap.ui.base.ManagedObject} | Returns this to allow method chaining |
sId
to the association identified by sAssociationName
and marks this ManagedObject as changed. This method does not avoid duplicates.
Note: This method is a low-level API as described in the class documentation. Applications or frameworks must not use this method to generically add an object to an association. Use the concrete method addXYZ for association 'XYZ' or the generic applySettings instead.
{string} | sAssociationName | the string identifying the association the object should be added to. |
{string|sap.ui.base.ManagedObject} | sId | the ID of the ManagedObject object to add; if empty, nothing is added; if a sap.ui.base.ManagedObject is given, its ID is added |
{boolean} | bSuppressInvalidate? | if true, this managed object as well as the newly associated object are not marked as changed |
{sap.ui.base.ManagedObject} | Returns this to allow method chaining |
mSettings
. If a property, aggregation, etc. is not listed in mSettings
, then its value is not changed by this method. For properties and 0..1 aggregations/associations, any given setting overwrites the current value. For 0..n aggregations, the given values are appended; event listeners are registered in addition to existing ones.
For the possible keys and values in mSettings
see the general documentation in sap.ui.base.ManagedObject or the specific documentation of the constructor of the concrete managed object class.
Experimental API:Since 1.11.2 support for the scope object for resolving string based type and formatter references in bindings is still experimental
{object} | mSettings | the settings to apply to this managed object |
{object} | oScope? | Scope object to resolve types and formatters |
- Experimental:
- Since 1.11.2 support for the scope object for resolving string based type and formatter references in bindings is still experimental
{sap.ui.base.ManagedObject} | Returns this to allow method chaining |
fnFunction
to the formatError
event of this sap.ui.base.ManagedObject
. 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.base.ManagedObject
itself.
Fired when a new value for a bound property should have been propagated from the model, but formatting the value failed with an exception.
{object} | oData? | An application-specific payload object that will be passed to the event handler along with the event object when firing the event |
{function} | fnFunction | The function to be called when the event occurs |
{object} | oListener? | Context object to call the event handler with. Defaults to this sap.ui.base.ManagedObject itself |
{sap.ui.base.ManagedObject} | Reference to this in order to allow method chaining |
fnFunction
to the modelContextChange
event of this sap.ui.base.ManagedObject
. 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.base.ManagedObject
itself.
Fired when models or contexts are changed on this object (either by calling setModel/setBindingContext or due to propagation)
{object} | oData? | An application-specific payload object that will be passed to the event handler along with the event object when firing the event |
{function} | fnFunction | The function to be called when the event occurs |
{object} | oListener? | Context object to call the event handler with. Defaults to this sap.ui.base.ManagedObject itself |
{sap.ui.base.ManagedObject} | Reference to this in order to allow method chaining |
fnFunction
to the parseError
event of this sap.ui.base.ManagedObject
. 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.base.ManagedObject
itself.
Fired when a new value for a bound property should have been propagated to the model, but parsing the value failed with an exception.
{object} | oData? | An application-specific payload object that will be passed to the event handler along with the event object when firing the event |
{function} | fnFunction | The function to be called when the event occurs |
{object} | oListener? | Context object to call the event handler with. Defaults to this sap.ui.base.ManagedObject itself |
{sap.ui.base.ManagedObject} | Reference to this in order to allow method chaining |
fnFunction
to the validationError
event of this sap.ui.base.ManagedObject
. 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.base.ManagedObject
itself.
Fired when a new value for a bound property should have been propagated to the model, but validating the value failed with an exception.
{object} | oData? | An application-specific payload object that will be passed to the event handler along with the event object when firing the event |
{function} | fnFunction | The function to be called when the event occurs |
{object} | oListener? | Context object to call the event handler with. Defaults to this sap.ui.base.ManagedObject itself |
{sap.ui.base.ManagedObject} | Reference to this in order to allow method chaining |
fnFunction
to the validationSuccess
event of this sap.ui.base.ManagedObject
. 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.base.ManagedObject
itself.
Fired after a new value for a bound property has been propagated to the model. Only fired, when the binding uses a data type.
{object} | oData? | An application-specific payload object that will be passed to the event handler along with the event object when firing the event |
{function} | fnFunction | The function to be called when the event occurs |
{object} | oListener? | Context object to call the event handler with. Defaults to this sap.ui.base.ManagedObject itself |
{sap.ui.base.ManagedObject} | Reference to this in order to allow method chaining |
The bound aggregation will use the given template, clone it for each item which exists in the bound list and set the appropriate binding context. This is a generic method which can be used to bind any aggregation to the model. A managed object may flag aggregations in the metamodel with bindable="bindable" to get typed bindSomething methods for those aggregations.
{string} | sName | the aggregation to bind |
{object} | oBindingInfo | the binding info |
{string} | oBindingInfo.path | the binding path |
{sap.ui.base.ManagedObject} | oBindingInfo.template | the template to clone for each item in the aggregation |
{boolean} | oBindingInfo.templateShareable?, Default: true | option to enable that the template will be shared which means that it won't be destroyed or cloned automatically |
{function} | oBindingInfo.factory | the factory function |
{number} | oBindingInfo.startIndex | the first entry of the list to be created |
{number} | oBindingInfo.length | the amount of entries to be created (may exceed the sizelimit of the model) |
{sap.ui.model.Sorter|sap.ui.model.Sorter[]} | oBindingInfo.sorter? | the initial sort order (optional) |
{sap.ui.model.Filter[]} | oBindingInfo.filters? | the predefined filters for this aggregation (optional) |
{string|function} | oBindingInfo.key | the name of the key property or a function getting the context as only parameter to calculate a key for entries. This can be used to improve udpate behaviour in models, where a key is not already available. |
{object} | oBindingInfo.parameters? | a map of parameters which is passed to the binding. The supported parameters are listed in the corresponding model-specific implementation of sap.ui.model.ListBinding or sap.ui.model.TreeBinding . |
{function} | oBindingInfo.groupHeaderFactory? | a factory function to generate custom group visualization (optional) |
{sap.ui.base.ManagedObject} | reference to the instance itself |
{string|object} | vPath | the binding path or an object with more detailed binding options |
{string} | vPath.path | the binding path |
{object} | vPath.parameters? | map of additional parameters for this binding |
{string} | vPath.model? | name of the model |
{object} | vPath.events? | map of event listeners for the binding events |
{object} | mParameters? | map of additional parameters for this binding (only taken into account when vPath is a string in that case the properties described for vPath above are valid here). The supported parameters are listed in the corresponding model-specific implementation of sap.ui.model.ContextBinding . |
{sap.ui.base.ManagedObject} | reference to the instance itself |
{string} | sName | the name of the property |
{object} | oBindingInfo | the binding information |
{string} | oBindingInfo.path | the binding path |
{string} | oBindingInfo.model? | the model identifier |
{function} | oBindingInfo.formatter? | the formatter function |
{boolean} | oBindingInfo.useRawValues? | determines if the parameters in the formatter functions should be passed as raw values or not. In this case the specified type for the binding is not used and the values are not formatted. Note: use this flag only when using multiple bindings. If you use only one binding and want raw values then simply don't specify a type for that binding. |
{sap.ui.model.Type|string} | oBindingInfo.type? | the sap.ui.model.Type object or class name |
{object} | oBindingInfo.formatOptions? | the format options to be used |
{object} | oBindingInfo.constraints? | the constraints for this value |
{sap.ui.model.BindingMode} | oBindingInfo.mode?, Default: Default | the binding mode to be used for this property binding (e.g. one way) |
{object} | oBindingInfo.parameters? | a map of parameters which is passed to the binding. The supported parameters are listed in the corresponding model-specific implementation of sap.ui.model.PropertyBinding . |
{object} | oBindingInfo.parts? | object for definding a read only composite binding which may have multiple binding paths also in different models. oTxt.bindValue({ parts: [ {path: "/firstName", type: new sap.ui.model.type.String()}, {path: "myModel2>/lastName"} ] }); |
{sap.ui.base.ManagedObject} | reference to the instance itself |
The ids within the newly created clone tree are derived from the original ids by appending the given sIdSuffix
(if no suffix is given, one will be created; it will be unique across multiple clone calls).
The oOptions
configuration object can have the following properties:
- The boolean value
cloneChildren
specifies wether associations/aggregations will be cloned - The boolean value
cloneBindings
specifies if bindings will be cloned
For each cloned object the following settings are cloned based on the metadata of the object and the defined options:
- all properties that are not bound. If cloneBinding is false even these properties will be cloned; the values are used by reference, they are not cloned
- all aggregated objects that are not bound. If cloneBinding is false even the ones that are bound will be cloned; they are all cloned recursively using the same
sIdSuffix
- all associated controls; when an association points to an object inside the cloned object tree, then the cloned association will be modified to that it points to the clone of the target object. When the association points to a managed object outside of the cloned object tree, then its target won't be changed.
- all models set via setModel(); used by reference
- all property and aggregation bindings (if cloneBindings is true); the pure binding infos (path, model name) are cloned, but all other information like template control or factory function, data type or formatter function are copied by reference. The bindings themselves are created anew as they are specific for the combination (object, property, model). As a result, any later changes to a binding of the original object are not reflected in the clone, but changes to e.g the type or template etc. are.
Each clone is created by first collecting the above mentioned settings and then creating a new instance with the normal constructor function. As a result, any side effects of mutator methods (setProperty etc.) or init hooks are repeated during clone creation. There is no need to override clone()
just to reproduce these internal settings!
Custom controls however can override clone()
to implement additional clone steps. They usually will first call clone()
on the super class and then modify the returned clone accordingly.
Applications must never provide the second parameter aLocaleIds
. It is determined automatically for the root object (and its non-existance also serves as an indicator for the root object). Specifying it will break the implementation of clone()
.
{string} | sIdSuffix? | a suffix to be appended to the cloned object id |
{string[]} | aLocalIds? | an array of local IDs within the cloned hierarchy (internally used) |
{Object} | oOptions? | configuration object |
{sap.ui.base.ManagedObject} | reference to the newly created clone |
After an object has been destroyed, it can no longer be used in!
Applications should call this method if they don't need the object any longer.
{boolean} | bSuppressInvalidate? | if true, this ManagedObject is not marked as changed |
sAggregationName
and empties the aggregation. If the aggregation did contain any object, this ManagedObject is marked as changed. Note: This method is a low-level API as described in the class documentation. Applications or frameworks must not use this method to generically destroy all objects in an aggregation. Use the concrete method destroyXYZ for aggregation 'XYZ' instead.
{string} | sAggregationName | the name of the aggregation |
{boolean} | bSuppressInvalidate? | if true, this ManagedObject is not marked as changed |
{sap.ui.base.ManagedObject} | Returns this to allow method chaining |
fnFunction
from the formatError
event of this sap.ui.base.ManagedObject
. The passed function and listener object must match the ones used for event registration.
{function} | fnFunction | The function to be called, when the event occurs |
{object} | oListener | Context object on which the given function had to be called |
{sap.ui.base.ManagedObject} | Reference to this in order to allow method chaining |
fnFunction
from the modelContextChange
event of this sap.ui.base.ManagedObject
. The passed function and listener object must match the ones used for event registration.
{function} | fnFunction | The function to be called, when the event occurs |
{object} | oListener | Context object on which the given function had to be called |
{sap.ui.base.ManagedObject} | Reference to this in order to allow method chaining |
fnFunction
from the parseError
event of this sap.ui.base.ManagedObject
. The passed function and listener object must match the ones used for event registration.
{function} | fnFunction | The function to be called, when the event occurs |
{object} | oListener | Context object on which the given function had to be called |
{sap.ui.base.ManagedObject} | Reference to this in order to allow method chaining |
fnFunction
from the validationError
event of this sap.ui.base.ManagedObject
. The passed function and listener object must match the ones used for event registration.
{function} | fnFunction | The function to be called, when the event occurs |
{object} | oListener | Context object on which the given function had to be called |
{sap.ui.base.ManagedObject} | Reference to this in order to allow method chaining |
fnFunction
from the validationSuccess
event of this sap.ui.base.ManagedObject
. The passed function and listener object must match the ones used for event registration.
{function} | fnFunction | The function to be called, when the event occurs |
{object} | oListener | Context object on which the given function had to be called |
{sap.ui.base.ManagedObject} | Reference to this in order to allow method chaining |
Take care: this operation might be expensive.
{boolean} | bRecursive | true, if all nested children should be returned. |
{boolean} | fnCondition | if given, the object is passed as a parameter to the. |
{sap.ui.base.ManagedObject[]} | array of child elements and controls |
formatError
to attached listeners. Expects the following event parameters:
element
of typesap.ui.base.ManagedObject
ManagedObject instance whose property should have received the model update.property
of typestring
Name of the property for which the binding should have been updated.type
of typesap.ui.model.Type
Data type used in the binding (if any).newValue
of typeany
New value (model representation) as propagated from the model.oldValue
of typeany
Old value (external representation) as previously stored in the ManagedObject.
{Map} | mArguments? | The arguments to pass along with the event |
{sap.ui.base.ManagedObject} | Reference to this in order to allow method chaining |
modelContextChange
to attached listeners. {Map} | mArguments? | The arguments to pass along with the event |
{sap.ui.base.ManagedObject} | Reference to this in order to allow method chaining |
parseError
to attached listeners. Expects the following event parameters:
element
of typesap.ui.base.ManagedObject
ManagedObject instance whose property initiated the model update.property
of typestring
Name of the property for which the bound model property should have been been updated.type
of typesap.ui.model.Type
Data type used in the binding.newValue
of typeany
New value (external representation) as parsed by the binding.oldValue
of typeany
Old value (external representation) as previously stored in the ManagedObject.message
of typestring
Localized message describing the parse error
{Map} | mArguments? | The arguments to pass along with the event |
{sap.ui.base.ManagedObject} | Reference to this in order to allow method chaining |
validationError
to attached listeners. Expects the following event parameters:
element
of typesap.ui.base.ManagedObject
ManagedObject instance whose property initiated the model update.property
of typestring
Name of the property for which the bound model property should have been been updated.type
of typesap.ui.model.Type
Data type used in the binding.newValue
of typeany
New value (external representation) as parsed and validated by the binding.oldValue
of typeany
Old value (external representation) as previously stored in the ManagedObject.message
of typestring
Localized message describing the validation issues
{Map} | mArguments? | The arguments to pass along with the event |
{sap.ui.base.ManagedObject} | Reference to this in order to allow method chaining |
validationSuccess
to attached listeners. Expects the following event parameters:
element
of typesap.ui.base.ManagedObject
ManagedObject instance whose property initiated the model update.property
of typestring
Name of the property for which the bound model property has been updated.type
of typesap.ui.model.Type
Data type used in the binding.newValue
of typeany
New value (external representation) as propagated to the model.Note: the model might modify (normalize) the value again and this modification will be stored in the ManagedObject. The 'newValue' parameter of this event contains the value before such a normalization.
oldValue
of typeany
Old value (external representation) as previously stored in the ManagedObject.
{Map} | mArguments? | The arguments to pass along with the event |
{sap.ui.base.ManagedObject} | Reference to this in order to allow method chaining |
If the aggregation does not contain any objects(s), the given oDefaultForCreation
(or null
) is set as new value of the aggregation and returned to the caller.
Note: the need to specify a default value and the fact that it is stored as new value of a so far empty aggregation is recognized as a shortcoming of this API but can no longer be changed for compatibility reasons.
Note: This method is a low-level API as described in the class documentation. Applications or frameworks must not use this method to generically read the content of an aggregation. Use the concrete method getXYZ for aggregation 'XYZ' instead.
{string} | sAggregationName | the name of the aggregation |
{sap.ui.base.ManagedObject|Array} | oDefaultForCreation | the object that is used in case the current aggregation is empty |
For associations of cardinality 0..1, a single string with the ID of an associated object is returned (if any). For cardinality 0..n, an array with the IDs of the associated objects is returned.
If the association does not contain any objects(s), the given oDefaultForCreation
is set as new value of the association and returned to the caller. The only supported values for oDefaultForCreation
are null
and undefined
in the case of cardinality 0..1 and null
, undefined
or an empty array ([]
) in case of cardinality 0..n. If the argument is omitted, null
is used independently from the cardinality.
Note: the need to specify a default value and the fact that it is stored as new value of a so far empty association is recognized as a shortcoming of this API but can no longer be changed for compatibility reasons.
Note: This method is a low-level API as described in the class documentation. Applications or frameworks must not use this method to generically retrieve the content of an association. Use the concrete method getXYZ for association 'XYZ' instead.
{string} | sAssociationName | the name of the association |
{object} | oDefaultForCreation | the object that is used in case the current aggregation is empty (only null or empty array allowed) |
{string|string[]} | the ID of the associated managed object or an array of such IDs; may be null if the association has not been populated |
{string} | sName | the name of the property or aggregation |
{sap.ui.model.Binding} | the binding for the given name |
If the object does not have a binding context set on itself and has no own Model set, it will use the first binding context defined in its parent hierarchy.
Note: to be compatible with future versions of this API, applications must not use the value null
, the empty string ""
or the string literals "null"
or "undefined"
as model name.
Note: A ManagedObject inherits binding contexts from the Core only when it is a descendant of an UIArea.
{string} | sModelName? | the name of the model or undefined |
{sap.ui.model.Context} | oContext The binding context of this object |
{string} | sName | the name of the property or aggregation |
{object} | the binding info object, containing at least a path property and, dependant of the binding type, additional properties |
{string} | sName | the name of the property or aggregation |
{string} | the binding path for the given name |
null
if this object hasn't been added to a parent yet. {sap.ui.base.EventProvider} | the parent event provider |
{sap.ui.base.ManagedObjectMetadata} | Metadata for the class of the object |
The name can be omitted to reference the default model or it must be a non-empty string.
Note: to be compatible with future versions of this API, applications must not use the value null
, the empty string ""
or the string literals "null"
or "undefined"
as model name.
{string|undefined} | sName? | name of the model to be retrieved |
{sap.ui.model.Model} | oModel |
{string} | sModelName | the name of the model |
{sap.ui.model.Binding} | the element binding for the given model name |
The origin info might contain additional information for translatable texts. The bookkeeping of this information is not active by default and must be activated by configuration. Even then, it might not be present for all properties and their values depending on where the value came form.
{string} | sPropertyName | the name of the property |
{object} | a map of properties describing the origin of this property value or null |
null
if this object hasn't been added to a parent yet. {sap.ui.base.ManagedObject} | The parent managed object or null |
sPropertyName
. Note: This method is a low-level API as described in the class documentation. Applications or frameworks must not use this method to generically retrieve the value of a property. Use the concrete method getXYZ for property 'XYZ' instead.
{string} | sPropertyName | the name of the property |
{any} | the value of the property |
Note: A ManagedObject inherits models from the Core only when it is a descendant of an UIArea.
{boolean} | whether a model reference exists or not |
Note: This method is a low-level API as described in the class documentation. Applications or frameworks must not use this method to generically determine the position of an object in an aggregation. Use the concrete method indexOfXYZ for aggregation 'XYZ' instead.
{string} | sAggregationName | the name of the aggregation |
{sap.ui.base.ManagedObject} | oObject | the ManagedObject whose index is looked for. |
{int} | the index of the provided managed object in the aggregation. |
oObject
to the aggregation named sAggregationName
at position iIndex
. If the given object is not valid with regard to the aggregation (if it is not an instance of the type specified for that aggregation) or when the method is called for an aggregation of cardinality 0..1, then an Error is thrown (see validateAggregation.
If the given index is out of range with respect to the current content of the aggregation, it is clipped to that range (0 for iIndex < 0, n for iIndex > n).
Please note that this method does not work as expected when an object is added that is already part of the aggregation. In order to change the index of an object inside an aggregation, first remove it, then insert it again.
Note: This method is a low-level API as described in the class documentation. Applications or frameworks must not use this method to generically insert an object into an aggregation. Use the concrete method insertXYZ for aggregation 'XYZ' instead.
{string} | sAggregationName | the string identifying the aggregation the managed object oObject should be inserted into. |
{sap.ui.base.ManagedObject} | oObject | the ManagedObject to add; if empty, nothing is inserted. |
{int} | iIndex | the 0 -based index the managed object should be inserted at; for a negative value iIndex , oObject is inserted at position 0; for a value greater than the current size of the aggregation, oObject is inserted at the last position |
{boolean} | bSuppressInvalidate? | if true, this ManagedObject as well as the added child are not marked as changed |
{sap.ui.base.ManagedObject} | Returns this to allow method chaining |
As
sap.ui.base.ManagedObject
"bubbles up" the invalidate, changes to child-Elements
will also result in rerendering of the whole sub tree. {string} | sName | the name of the property or aggregation |
{boolean} | whether a binding exists for the given name |
{string} | sName | the aggregation to bind (e.g. nodes for a tree managed object) |
{boolean} | whether tree binding should be used or list binding. Default is false. Override method to change this behavior. |
{string} | sName | The property name |
{array} | aMessages | The messages |
- Since:
- 1.28
sAggregationName
with cardinality 0..n. The removed object is not destroyed nor is it marked as changed.
If the given object is found in the aggreation, it is removed, it's parent relationship is unset and this ManagedObject is marked as changed. The removed object is returned as result of this method. If the object could not be found, undefined
is returned.
This method must only be called for aggregations of cardinality 0..n. The only way to remove objects from a 0..1 aggregation is to set a null
value for them.
Note: This method is a low-level API as described in the class documentation. Applications or frameworks must not use this method to generically remove an object from an aggregation. Use the concrete method removeXYZ for aggregation 'XYZ' instead.
{string} | sAggregationName | the string identifying the aggregation that the given object should be removed from |
{int|string|sap.ui.base.ManagedObject} | vObject | the position or ID of the ManagedObject that should be removed or that ManagedObject itself; if vObject is invalid, a negative value or a value greater or equal than the current size of the aggregation, nothing is removed. |
{boolean} | bSuppressInvalidate? | if true, this ManagedObject is not marked as changed |
{sap.ui.base.ManagedObject} | the removed object or null |
sAggregationName
. The removed objects are not destroyed nor are they marked as changed.
Additionally, it clears the parent relationship of all removed objects, marks this ManagedObject as changed and returns an array with the removed objects.
If the aggregation did not contain any objects, an empty array is returned and this ManagedObject is not marked as changed.
Note: This method is a low-level API as described in the class documentation. Applications or frameworks must not use this method to generically remove all objects from an aggregation. Use the concrete method removeAllXYZ for aggregation 'XYZ' instead.
{string} | sAggregationName | the name of the aggregation |
{boolean} | bSuppressInvalidate? | if true, this ManagedObject is not marked as changed |
sAssociationName
and returns an array with their IDs. This ManagedObject is marked as changed, if the association contained any objects. Note: This method is a low-level API as described in the class documentation. Applications or frameworks must not use this method to generically remove all object from an association. Use the concrete method removeAllXYZ for association 'XYZ' instead.
{string} | sAssociationName | the name of the association |
{boolean} | bSuppressInvalidate? | if true, this ManagedObject is not marked as changed |
sAssociationName
. If an object is removed, the Id of that object is returned and this ManagedObject is marked as changed. Otherwise undefined
is returned.
If the same object was added multiple times to the same association, only a single occurence of it will be removed by this method. If the object is not found or if the parameter can't be interpreted neither as a ManagedObject (or id) nor as an index in the assocation, nothing will be removed. The same is true if an index is given and if that index is out of range for the association.
Note: This method is a low-level API as described in the class documentation. Applications or frameworks must not use this method to generically remove an object from an association. Use the concrete method removeXYZ for association 'XYZ' instead.
{string} | sAssociationName | the string identifying the association the ManagedObject should be removed from. |
{int|string|sap.ui.base.ManagedObject} | vObject | the position or ID of the ManagedObject to remove or the ManagedObject itself; if vObject is invalid input, a negative value or a value greater or equal than the current size of the association, nothing is removed |
{boolean} | bSuppressInvalidate? | if true, the managed object is not marked as changed |
If the given object is not valid with regard to the aggregation (if it is not an instance of the type specified for that aggregation) or when the method is called for an aggregation of cardinality 0..n, then an Error is thrown (see validateAggregation.
If the new object is the same as the currently aggregated object, then the internal state is not modified and this ManagedObject is not marked as changed.
If the given object is different, the parent of a previously aggregated object is cleared (it must have been this ManagedObject before), the parent of the given object is set to this ManagedObject and invalidate is called for this object.
Note that this method does neither return nor destroy the previously aggregated object. This behavior is inherited by named set methods (see below) in subclasses. To avoid memory leaks, applications therefore should first get the aggregated object, keep a reference to it or destroy it, depending on their needs, and only then set a new object.
Note that ManagedObject only implements a single level of change tracking: if a first call to setAggregation recognizes a change, 'invalidate' is called. If another call to setAggregation reverts that change, invalidate() will be called again, the new status is not recognized as being 'clean' again.
Note: This method is a low-level API as described in the class documentation. Applications or frameworks must not use this method to generically set an object in an aggregation. Use the concrete method setXYZ for aggregation 'XYZ' or the generic applySettings instead.
{string} | sAggregationName | name of an 0..1 aggregation |
{object} | oObject | the managed object that is set as aggregated object |
{boolean} | bSuppressInvalidate? | if true, this ManagedObject is not marked as changed |
{Error} |
{sap.ui.base.ManagedObject} | Returns this to allow method chaining |
The associated object can either be given by itself or by its id. If null
or undefined
is given, the association is cleared.
Note: This method is a low-level API as described in the class documentation. Applications or frameworks must not use this method to generically set an object in an association. Use the concrete method setXYZ for association 'XYZ' or the generic applySettings instead.
{string} | sAssociationName | name of the association |
{string|sap.ui.base.ManagedObject} | sId | the ID of the managed object that is set as an association, or the managed object itself or null |
{boolean} | bSuppressInvalidate? | if true, the managed objects invalidate method is not called |
{sap.ui.base.ManagedObject} | Returns this to allow method chaining |
Note: to be compatible with future versions of this API, applications must not use the value null
, the empty string ""
or the string literals "null"
or "undefined"
as model name.
Note: A ManagedObject inherits binding contexts from the Core only when it is a descendant of an UIArea.
{Object} | oContext | the new binding context for this object |
{string} | sModelName? | the name of the model to set the context for or undefined |
{sap.ui.base.ManagedObject} | reference to the instance itself |
The sName
must either be undefined
(or omitted) or a non-empty string. When the name is omitted, the default model is set/unset.
When oModel
is null
or undefined
, a previously set model with that name is removed from this ManagedObject. If an ancestor (parent, UIArea or Core) has a model with that name, this ManagedObject will immediately inherit that model from its ancestor.
All local bindings that depend on the given model name, are updated (created if the model references became complete now; updated, if any model reference has changed; removed if the model references became incomplete now).
Any change (new model, removed model, inherited model) is also applied to all aggregated descendants as long as a descendant doesn't have its own model set for the given name.
Note: to be compatible with future versions of this API, applications must not use the value null
, the empty string ""
or the string literals "null"
or "undefined"
as model name.
Note: By design, it is not possible to hide an inherited model by setting a null
or undefined
model. Applications can set an empty model to achieve the same.
Note: A ManagedObject inherits models from the Core only when it is a descendant of an UIArea.
{sap.ui.model.Model} | oModel | the model to be set or null or undefined |
{string} | sName? | the name of the model or undefined |
{sap.ui.base.ManagedObject} | this to allow method chaining |
If the value is not valid with regard to the declared data type of the property, an Error is thrown. In case null
or undefined
is passed, the default value for this property is used (see validateProperty. If the validated and normalized oValue
equals the current value of the property, the internal state of this object is not changed. If the value changes, it is stored internally and the invalidate method is called on this object. In the case of TwoWay databinding, the bound model is informed about the property change.
Note that ManagedObject only implements a single level of change tracking: if a first call to setProperty recognizes a change, 'invalidate' is called. If another call to setProperty reverts that change, invalidate() will be called again, the new status is not recognized as being 'clean' again.
Note: This method is a low level API as described in the class documentation. Applications or frameworks must not use this method to generically set a property. Use the concrete method setXYZ for property 'XYZ' or the generic applySettings instead.
{string} | sPropertyName | name of the property to set |
{any} | oValue | value to set the property to |
{boolean} | bSuppressInvalidate? | if true, the managed object is not marked as changed |
{sap.ui.base.ManagedObject} | Returns this to allow method chaining |
Mainly useful for tracing purposes.
{string} | a string description of this managed object |
{string} | sName | the name of the aggregation |
{boolean} | bSuppressReset | whether the reset to empty aggregation when unbinding should be suppressed |
{sap.ui.base.ManagedObject} | reference to the instance itself |
{string} | sModelName? | name of the model to remove the context for. |
{sap.ui.base.ManagedObject} | reference to the instance itself |
{string} | sName | the name of the property |
{boolean} | bSuppressReset | whether the reset to the default value when unbinding should be suppressed |
{sap.ui.base.ManagedObject} | reference to the instance itself |
This method is already called by setAggregation, addAggregation and insertAggregation. In many cases, subclasses of ManagedObject don't need to call it again in their mutator methods.
{string} | sAggregationName | the name of the aggregation |
{sap.ui.base.ManagedObject|any} | oObject | the aggregated object or a primitive value |
{boolean} | bMultiple | whether the caller assumes the aggregation to have cardinality 0..n |
Error if no aggregation with the given name is found or the given value does not fit to the aggregation type |
{sap.ui.base.ManagedObject|any} | the passed object |
In case null
or undefined
is passed, the default value for this property is used as value. If no default value is defined for the property, the default value of the type of the property is used.
If the property has a data type that is an instance of sap.ui.base.DataType and if a normalize
function is defined for that type, that function will be called with the resulting value as only argument. The result of the function call is then used instead of the raw value.
This method is called by setProperty. In many cases, subclasses of ManagedObject don't need to call it themselves.
{string} | sPropertyName | the name of the property |
{any} | oValue | the value |
Error if no property with the given name is found or the given value does not fit to the property type |
{any} | the normalized value for the passed value or for the default value if null or undefined was passed |
{string} | sPath | the binding path |
- Deprecated:
- Since 1.11.1, please use bindElement instead.
{sap.ui.base.ManagedObject} | reference to the instance itself |
{string} | sModelName? | name of the model to remove the context for. |
- Deprecated:
- Since 1.11.1, please use unbindElement instead.
{sap.ui.base.ManagedObject} | reference to the instance itself |