Class sap.ui.model.CompositeDataStateModule: sap/ui/model/CompositeDataState
Provides and update the status data of a binding. Depending on the models state and controls state changes, the data state is used to propagated changes to a control. The control can react on these changes by implementing the refreshDataState
method for the control. Here the the data state object is passed as a parameter.
Using the getChanges method the control can determine the changed properties and their old and new value.
//sample implementation to handle message changes myControl.prototype.refreshDataState = function(oDataState) { var aMessages = oDataState.getChanges().messages; if (aMessages) { for (var i = 0; i < aMessages.length; i++) { console.log(aMessages.message); } } } //sample implementation to handle laundering state myControl.prototype.refreshDataState = function(oDataState) { var bLaundering = oDataState.getChanges().laundering || false; this.setBusy(bLaundering); } //sample implementation to handle dirty state myControl.prototype.refreshDataState = function(oDataState) { if (oDataState.isDirty()) console.log("Control " + this.getId() + " is now dirty"); }
Using the getProperty method the control can read the properties of the data state. The properties are
value
The value formatted by the formatter of the bindingoriginalValue
The original value of the model formatted by the formatter of the bindinginvalidValue
The control value that was tried to be applied to the model but was rejected by a type validationmodelMessages
The messages that were applied to the binding by thesap.ui.model.MessageModel
controlMessages
The messages that were applied due to type validation errorsmessages
All messages of the data statedirty
true if the value was not yet confirmed by the server
Constructor Summary
Method Summary
sap.ui.model.CompositeDataState.extend(sClassName, oClassInfo?, FNMetaImpl?)Creates a new subclass of class sap.ui.model.CompositeDataState with name
sClassName
and enriches it with the information contained in oClassInfo
.sap.ui.model.CompositeDataState.getMetadata()Returns a metadata object for class sap.ui.model.CompositeDataState.
getChanges()Returns the changes of the data state in a map that the control can use in the
refreshDataState
method.Methods borrowed from class sap.ui.model.DataState
Methods borrowed from class sap.ui.base.Object
Method Detail
sap.ui.model.CompositeDataState.extend(sClassName, oClassInfo?, FNMetaImpl?): function
Creates a new subclass of class sap.ui.model.CompositeDataState 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.model.DataState.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.CompositeDataState.getMetadata(): sap.ui.base.Metadata
Returns a metadata object for class sap.ui.model.CompositeDataState.
Returns:
{sap.ui.base.Metadata} | Metadata object describing this class |
changed(bNewState?): boolean
Returns or sets whether the data state is changed. As long as changed was not set to false the data state is dirty and the corresponding binding will fire data state change events.
Parameters:
{boolean} | bNewState? | the optional new state |
Returns:
{boolean} | whether the data state was changed. |
getChanges(): map
Returns the changes of the data state in a map that the control can use in the
refreshDataState
method. The changed property's name is the key in the map. Each element in the map contains an object of below structure. { oldValue : The old value of the property, value : The new value of the property }The map only contains the changed properties.
Returns:
{map} | the changed of the data state |
getControlMessages(the): sap.ui.model.DataState
Sets an array of control state messages.
Parameters:
{sap.ui.core.Message[]} | the | control messages |
Returns:
{sap.ui.model.DataState} | this to allow method chaining |
getInvalidValue(): any
Returns the dirty value of a binding that was rejected by a type validation. This value was of an incorrect type and could not be applied to the model. If the value was not rejected it will return null. In this case the current model value can be accessed using the
getValue
method. Returns:
{any} | the value that was rejected or null |
getMessages(): sap.ui.core.Message[]
Returns the array of all state messages or null. This combines the model and control messages.
Returns:
{sap.ui.core.Message[]} | the array of all messages or null if no {link:sap.ui.core.messages.ModelManager ModelManager} is used. |
getModelMessages(): sap.ui.core.Message[]
Returns the array of state messages of the model or undefined
Returns:
{sap.ui.core.Message[]} | the array of messages of the model or null if no {link:sap.ui.core.messages.ModelManager ModelManager} is used. |
isControlDirty(): boolean
Returns whether the data state is dirty in the UI control. A data state is dirty in the UI control if the entered value did not yet pass the type validation.
Returns:
{boolean} | true if the data state is dirty |