Abstract Class sap.ui.model.ModelModule: sap/ui/model/Model


This is an abstract base class for model objects.

Constructor Summary
new sap.ui.model.Model()Constructor for a new Model.
Event Summary
parseError(oEvent)The 'parseError' event is fired when parsing of a model document (e.g.
requestCompleted(oEvent)The 'requestCompleted' event is fired, after a request has been completed (includes receiving a response), no matter whether the request succeeded or not.
requestFailed(oEvent)The 'requestFailed' event is fired, when data retrieval from a backend failed.
requestSent(oEvent)The 'requestSent' event is fired, after a request has been sent to a backend.
Method Summary
sap.ui.model.Model.extend(sClassName, oClassInfo?, FNMetaImpl?)Creates a new subclass of class sap.ui.model.Model with name sClassName and enriches it with the information contained in oClassInfo.
sap.ui.model.Model.getMetadata()Returns a metadata object for class sap.ui.model.Model.
attachParseError(oData?, fnFunction, oListener?)Attach event-handler fnFunction to the 'parseError' event of this sap.ui.model.Model.
attachRequestCompleted(oData?, fnFunction, oListener?)Attach event-handler fnFunction to the 'requestCompleted' event of this sap.ui.model.Model.
attachRequestFailed(oData?, fnFunction, oListener?)Attach event-handler fnFunction to the 'requestFailed' event of this sap.ui.model.Model.
attachRequestSent(oData?, fnFunction, oListener?)Attach event-handler fnFunction to the 'requestSent' event of this sap.ui.model.Model.
bindContext(sPath, oContext?, mParameters?, oEvents?)Create ContextBinding
bindList(sPath, oContext?, aSorters?, aFilters?, mParameters?)Implement in inheriting classes
bindProperty(sPath, oContext?, mParameters?)Implement in inheriting classes
bindTree(sPath, oContext?, aFilters?, mParameters?, aSorters?)Implement in inheriting classes
createBindingContext(sPath, oContext?, mParameters?, fnCallBack?, bReload?)Implement in inheriting classes
destroy()Destroys the model and clears the model data.
destroyBindingContext(oContext)Implement in inheriting classes
detachParseError(fnFunction, oListener)Detach event-handler fnFunction from the 'parseError' event of this sap.ui.model.Model.
detachRequestCompleted(fnFunction, oListener)Detach event-handler fnFunction from the 'requestCompleted' event of this sap.ui.model.Model.
detachRequestFailed(fnFunction, oListener)Detach event-handler fnFunction from the 'requestFailed' event of this sap.ui.model.Model.
detachRequestSent(fnFunction, oListener)Detach event-handler fnFunction from the 'requestSent' event of this sap.ui.model.Model.
fireParseError(mArguments?)Fire event parseError to attached listeners.
fireRequestCompleted(mArguments?)Fire event requestCompleted to attached listeners.
fireRequestFailed(mArguments?)Fire event requestFailed to attached listeners.
fireRequestSent(mArguments?)Fire event requestSent to attached listeners.
getDefaultBindingMode()Get the default binding mode for the model
getMessagesByPath(sPath)Get messages for path
getMetaModel()Returns the meta model associated with this model if it is available for the concrete model type.
getObject(sPath, oContext?)Implement in inheriting classes
getOriginalProperty(sPath, oContext?)Returns the original value for the property with the given path and context.
getProperty(sPath, oContext?)Implement in inheriting classes
isBindingModeSupported(sMode)Check if the specified binding mode is supported by the model.
isLegacySyntax()Returns whether legacy path syntax is used
refresh(bForceUpdate)Refresh the model.
setDefaultBindingMode(sMode)Set the default binding mode for the model.
setLegacySyntax(bLegacySyntax)Enables legacy path syntax handling

This defines, whether relative bindings, which do not have a defined binding context, should be compatible to earlier releases which means they are resolved relative to the root element or handled strict and stay unresolved until a binding context is set

setMessages(mMessages)Sets messages
setSizeLimit(iSizeLimit)Set the maximum number of entries which are used for list bindings.
Methods borrowed from class sap.ui.base.Object
Constructor Detail
new sap.ui.model.Model()
Constructor for a new Model.

Every Model is a MessageProcessor that is able to handle Messages with the normal binding path syntax in the target.

Event Detail
parseError(oEvent)
The 'parseError' event is fired when parsing of a model document (e.g. XML response) fails.
Parameters:
{sap.ui.base.Event}oEvent
{sap.ui.base.EventProvider}oEvent.getSource
{object}oEvent.getParameters
{int}oEvent.getParameters.errorCode
{string}oEvent.getParameters.url
{string}oEvent.getParameters.reason
{string}oEvent.getParameters.srcText
{int}oEvent.getParameters.line
{int}oEvent.getParameters.linepos
{int}oEvent.getParameters.filepos
requestCompleted(oEvent)
The 'requestCompleted' event is fired, after a request has been completed (includes receiving a response), no matter whether the request succeeded or not.

Note: Subclasses might add additional parameters to the event object. Optional parameters can be omitted.

Parameters:
{sap.ui.base.Event}oEvent
{sap.ui.base.EventProvider}oEvent.getSource
{object}oEvent.getParameters
{string}oEvent.getParameters.url The url which was sent to the backend
{string}oEvent.getParameters.type? The type of the request (if available)
{boolean}oEvent.getParameters.success if the request has been successful or not. In case of errors consult the optional errorobject parameter.
{object}oEvent.getParameters.errorobject? If the request failed the error if any can be accessed in this property.
{boolean}oEvent.getParameters.async? If the request is synchronous or asynchronous (if available)
{string}oEvent.getParameters.info? Additional information for the request (if available) deprecated
{object}oEvent.getParameters.infoObject? Additional information for the request (if available)
requestFailed(oEvent)
The 'requestFailed' event is fired, when data retrieval from a backend failed.

Note: Subclasses might add additional parameters to the event object. Optional parameters can be omitted.

Parameters:
{sap.ui.base.Event}oEvent
{sap.ui.base.EventProvider}oEvent.getSource
{object}oEvent.getParameters
{string}oEvent.getParameters.message A text that describes the failure.
{string}oEvent.getParameters.statusCode HTTP status code returned by the request (if available)
{string}oEvent.getParameters.statusText The status as a text, details not specified, intended only for diagnosis output
{string}oEvent.getParameters.responseText? Response that has been received for the request, as a text string
requestSent(oEvent)
The 'requestSent' event is fired, after a request has been sent to a backend.

Note: Subclasses might add additional parameters to the event object. Optional parameters can be omitted.

Parameters:
{sap.ui.base.Event}oEvent
{sap.ui.base.EventProvider}oEvent.getSource
{object}oEvent.getParameters
{string}oEvent.getParameters.url The url which is sent to the backend
{string}oEvent.getParameters.type? The type of the request (if available)
{boolean}oEvent.getParameters.async? If the request is synchronous or asynchronous (if available)
{string}oEvent.getParameters.info? Additional information for the request (if available) deprecated
{object}oEvent.getParameters.infoObject? Additional information for the request (if available)
Method Detail
sap.ui.model.Model.extend(sClassName, oClassInfo?, FNMetaImpl?): function
Creates a new subclass of class sap.ui.model.Model 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.message.MessageProcessor.extend.

Parameters:
{string}sClassName Name of the class being created
{object}oClassInfo? Object literal with information about the class
{function}FNMetaImpl? Constructor function for the metadata object; if not given, it defaults to sap.ui.core.ElementMetadata
Returns:
{function} Created class / constructor function
sap.ui.model.Model.getMetadata(): sap.ui.base.Metadata
Returns a metadata object for class sap.ui.model.Model.
Returns:
{sap.ui.base.Metadata} Metadata object describing this class
attachParseError(oData?, fnFunction, oListener?): sap.ui.model.Model
Attach event-handler fnFunction to the 'parseError' event of this sap.ui.model.Model.
Parameters:
{object}oData? The object, that should be passed along with the event-object when firing the event.
{function}fnFunction The function to call, when the event occurs. This function will be called on the oListener-instance (if present) or in a 'static way'.
{object}oListener? Object on which to call the given function. If empty, the global context (window) is used.
Returns:
{sap.ui.model.Model}this to allow method chaining
attachRequestCompleted(oData?, fnFunction, oListener?): sap.ui.model.Model
Attach event-handler fnFunction to the 'requestCompleted' event of this sap.ui.model.Model.
Parameters:
{object}oData? The object, that should be passed along with the event-object when firing the event.
{function}fnFunction The function to call, when the event occurs. This function will be called on the oListener-instance (if present) or in a 'static way'.
{object}oListener? Object on which to call the given function. If empty, the global context (window) is used.
Returns:
{sap.ui.model.Model}this to allow method chaining
attachRequestFailed(oData?, fnFunction, oListener?): sap.ui.model.Model
Attach event-handler fnFunction to the 'requestFailed' event of this sap.ui.model.Model.
Parameters:
{object}oData? The object, that should be passed along with the event-object when firing the event.
{function}fnFunction The function to call, when the event occurs. This function will be called on the oListener-instance (if present) or in a 'static way'.
{object}oListener? Object on which to call the given function. If empty, this Model is used.
Returns:
{sap.ui.model.Model}this to allow method chaining
attachRequestSent(oData?, fnFunction, oListener?): sap.ui.model.Model
Attach event-handler fnFunction to the 'requestSent' event of this sap.ui.model.Model.
Parameters:
{object}oData? The object, that should be passed along with the event-object when firing the event.
{function}fnFunction The function to call, when the event occurs. This function will be called on the oListener-instance (if present) or in a 'static way'.
{object}oListener? Object on which to call the given function. If empty, the global context (window) is used.
Returns:
{sap.ui.model.Model}this to allow method chaining
bindContext(sPath, oContext?, mParameters?, oEvents?): sap.ui.model.ContextBinding
Create ContextBinding
Parameters:
{string|object}sPath the path pointing to the property that should be bound or an object which contains the following parameter properties: path, context, parameters
{object}oContext? the context object for this databinding (optional)
{object}mParameters? additional model specific parameters (optional)
{object}oEvents? event handlers can be passed to the binding ({change:myHandler})
Returns:
{sap.ui.model.ContextBinding}
bindList(sPath, oContext?, aSorters?, aFilters?, mParameters?): sap.ui.model.ListBinding
Implement in inheriting classes
Parameters:
{string}sPath the path pointing to the list / array that should be bound
{object}oContext? the context object for this databinding (optional)
{sap.ui.model.Sorter}aSorters? initial sort order (can be either a sorter or an array of sorters) (optional)
{array}aFilters? predefined filter/s (can be either a filter or an array of filters) (optional)
{object}mParameters? additional model specific parameters (optional)
Returns:
{sap.ui.model.ListBinding}
bindProperty(sPath, oContext?, mParameters?): sap.ui.model.PropertyBinding
Implement in inheriting classes
Parameters:
{string}sPath the path pointing to the property that should be bound
{object}oContext? the context object for this databinding (optional)
{object}mParameters? additional model specific parameters (optional)
Returns:
{sap.ui.model.PropertyBinding}
bindTree(sPath, oContext?, aFilters?, mParameters?, aSorters?): sap.ui.model.TreeBinding
Implement in inheriting classes
Parameters:
{string}sPath the path pointing to the tree / array that should be bound
{object}oContext? the context object for this databinding (optional)
{array}aFilters? predefined filter/s contained in an array (optional)
{object}mParameters? additional model specific parameters (optional)
{array}aSorters? predefined sap.ui.model.sorter/s contained in an array (optional)
Returns:
{sap.ui.model.TreeBinding}
createBindingContext(sPath, oContext?, mParameters?, fnCallBack?, bReload?): sap.ui.model.Context
Implement in inheriting classes
Parameters:
{string}sPath the path to create the new context from
{object}oContext? the context which should be used to create the new binding context
{object}mParameters? the parameters used to create the new binding context
{function}fnCallBack? the function which should be called after the binding context has been created
{boolean}bReload? force reload even if data is already available. For server side models this should refetch the data from the server
Returns:
{sap.ui.model.Context} the binding context, if it could be created synchronously
destroy()
Destroys the model and clears the model data. A model implementation may override this function and perform model specific cleanup tasks e.g. abort requests, prevent new requests, etc.
See:
sap.ui.base.Object.prototype.destroy
destroyBindingContext(oContext)
Implement in inheriting classes
Parameters:
{object}oContext to destroy
detachParseError(fnFunction, oListener): sap.ui.model.Model
Detach event-handler fnFunction from the 'parseError' event of this sap.ui.model.Model.

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

Parameters:
{function}fnFunction The function to call, when the event occurs.
{object}oListener Object on which the given function had to be called.
Returns:
{sap.ui.model.Model}this to allow method chaining
detachRequestCompleted(fnFunction, oListener): sap.ui.model.Model
Detach event-handler fnFunction from the 'requestCompleted' event of this sap.ui.model.Model.

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

Parameters:
{function}fnFunction The function to call, when the event occurs.
{object}oListener Object on which the given function had to be called.
Returns:
{sap.ui.model.Model}this to allow method chaining
detachRequestFailed(fnFunction, oListener): sap.ui.model.Model
Detach event-handler fnFunction from the 'requestFailed' event of this sap.ui.model.Model.

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

Parameters:
{function}fnFunction The function to call, when the event occurs.
{object}oListener Object on which the given function had to be called.
Returns:
{sap.ui.model.Model}this to allow method chaining
detachRequestSent(fnFunction, oListener): sap.ui.model.Model
Detach event-handler fnFunction from the 'requestSent' event of this sap.ui.model.Model.

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

Parameters:
{function}fnFunction The function to call, when the event occurs.
{object}oListener Object on which the given function had to be called.
Returns:
{sap.ui.model.Model}this to allow method chaining
fireParseError(mArguments?): sap.ui.model.Model
Fire event parseError to attached listeners.
Parameters:
{object}mArguments? the arguments to pass along with the event.
{int}mArguments.errorCode?
{string}mArguments.url?
{string}mArguments.reason?
{string}mArguments.srcText?
{int}mArguments.line?
{int}mArguments.linepos?
{int}mArguments.filepos?
Returns:
{sap.ui.model.Model}this to allow method chaining
fireRequestCompleted(mArguments?): sap.ui.model.Model
Fire event requestCompleted to attached listeners.
Parameters:
{object}mArguments? the arguments to pass along with the event.
{string}mArguments.url? The url which was sent to the backend.
{string}mArguments.type? The type of the request (if available)
{boolean}mArguments.async? If the request was synchronous or asynchronous (if available)
{string}mArguments.info? additional information for the request (if available) deprecated
{object}mArguments.infoObject? Additional information for the request (if available)
Returns:
{sap.ui.model.Model}this to allow method chaining
fireRequestFailed(mArguments?): sap.ui.model.Model
Fire event requestFailed to attached listeners.
Parameters:
{object}mArguments? the arguments to pass along with the event.
{string}mArguments.message? A text that describes the failure.
{string}mArguments.statusCode? HTTP status code returned by the request (if available)
{string}mArguments.statusText? The status as a text, details not specified, intended only for diagnosis output
{string}mArguments.responseText? Response that has been received for the request ,as a text string
Returns:
{sap.ui.model.Model}this to allow method chaining
fireRequestSent(mArguments?): sap.ui.model.Model
Fire event requestSent to attached listeners.
Parameters:
{object}mArguments? the arguments to pass along with the event.
{string}mArguments.url? The url which is sent to the backend.
{string}mArguments.type? The type of the request (if available)
{boolean}mArguments.async? If the request is synchronous or asynchronous (if available)
{string}mArguments.info? additional information for the request (if available) deprecated
{object}mArguments.infoObject? Additional information for the request (if available)
Returns:
{sap.ui.model.Model}this to allow method chaining
getDefaultBindingMode(): sap.ui.model.BindingMode
Get the default binding mode for the model
Returns:
{sap.ui.model.BindingMode} default binding mode of the model
getMessagesByPath(sPath)
Get messages for path
Parameters:
{string}sPath The binding path
getMetaModel(): sap.ui.model.MetaModel
Returns the meta model associated with this model if it is available for the concrete model type.
Returns:
{sap.ui.model.MetaModel} The meta model or undefined if no meta model exists.
getObject(sPath, oContext?)
Implement in inheriting classes
Parameters:
{string}sPath the path to where to read the object
{object}oContext? the context with which the path should be resolved
getOriginalProperty(sPath, oContext?): any
Returns the original value for the property with the given path and context. The original value is the value that was last responded by a server if using a server model implementation.
Parameters:
{string}sPath the path/name of the property
{object}oContext? the context if available to access the property value
Returns:
{any} vValue the value of the property
getProperty(sPath, oContext?)
Implement in inheriting classes
Parameters:
{string}sPath the path to where to read the attribute value
{object}oContext? the context with which the path should be resolved
isBindingModeSupported(sMode)
Check if the specified binding mode is supported by the model.
Parameters:
{sap.ui.model.BindingMode}sMode the binding mode to check
isLegacySyntax(): boolean
Returns whether legacy path syntax is used
Returns:
{boolean}
refresh(bForceUpdate)
Refresh the model. This will check all bindings for updated data and update the controls if data has been changed.
Parameters:
{boolean}bForceUpdate Update controls even if data has not been changed
setDefaultBindingMode(sMode): sap.ui.model.Model
Set the default binding mode for the model. If the default binding mode should be changed, this method should be called directly after model instance creation and before any binding creation. Otherwise it is not guaranteed that the existing bindings will be updated with the new binding mode.
Parameters:
{sap.ui.model.BindingMode}sMode the default binding mode to set for the model
Returns:
{sap.ui.model.Model} this pointer for chaining
setLegacySyntax(bLegacySyntax)
Enables legacy path syntax handling

This defines, whether relative bindings, which do not have a defined binding context, should be compatible to earlier releases which means they are resolved relative to the root element or handled strict and stay unresolved until a binding context is set

Parameters:
{boolean}bLegacySyntax the path syntax to use
setMessages(mMessages)
Sets messages
Parameters:
{object}mMessages Messages for this model
setSizeLimit(iSizeLimit)
Set the maximum number of entries which are used for list bindings.
Parameters:
{int}iSizeLimit collection size limit