| Package | mx.data |
| Class | public class DataStore |
| Inheritance | DataStore EventDispatcher Object |
commit() method
send only changes made to that DataService.
When you use managed associations, the default changes so that all
DataService instances that share the same set of channels and have
the same value of the use-transactions flag share the same DataStore.
When you are sharing a DataStore, a single call to the commit() method applies
to all changes made by all DataService instances sharing that DataStore.
The default changes because with managed associations, it is
possible that changes between destinations can have dependencies
so it is important to preserve the order of operations
on the client when sending messages to the server.
If you want to change the default, you can create your own DataStore
and manually assign it to one or more dataStore properties of a DataService.
Do this when you first initialize your DataService, before you have
issued any other DataService api calls such as fill or getItem. Note that
all DataServices which share the same DataStore should be using the same
set of channels and should also have the same value of the use-transactions
flag.
See also
| Property | Defined by | ||
|---|---|---|---|
| autoCommit : Boolean
If set to
true, operations that modify the state managed by the
DataService are committed immediately. | DataStore | ||
| autoMerge : Boolean
If set to
false, when changes are pushed from the server to
the client they are not immediately applied. | DataStore | ||
| commitRequired : Boolean
[read-only]
Indicates if there are pending updates that must be committed.
| DataStore | ||
| conflicts : Conflicts
[read-only]
Returns a list of conflicts for all managed items.
| DataStore | ||
| connected : Boolean
[read-only]
Indicates whether the DataStore is connected.
| DataStore | ||
![]() | constructor : Object
A reference to the class object or constructor function for a given object instance.
| Object | |
| mergeRequired : Boolean
[read-only]
Indicates if there are any pending changes that must be
merged.
| DataStore | ||
![]() | prototype : Object
[static]
A reference to the prototype object of a class or function object.
| Object | |
| requestTimeout : int
Provides access to the request timeout in seconds for an operation.
| DataStore | ||
| Method | Defined by | ||
|---|---|---|---|
|
Normally, a DataStore is created automatically for you but you
can create your own DataStore and assign it to the
dataStore property
of a DataService. | DataStore | ||
![]() |
addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false):void
Registers an event listener object with an EventDispatcher object so that the listener
receives notification of an event.
| EventDispatcher | |
|
Commits any pending changes for all collections currently managed by
this DataService.
| DataStore | ||
![]() |
Dispatches an event into the event flow.
| EventDispatcher | |
![]() |
Checks whether the EventDispatcher object has any listeners registered for a specific type
of event.
| EventDispatcher | |
![]() |
Indicates whether an object has a specified property defined.
| Object | |
![]() |
Indicates whether an instance of the Object class is in the prototype chain of the object specified
as the parameter.
| Object | |
|
Merges any pending updates into the managed set of objects.
| DataStore | ||
![]() |
Indicates whether the specified property exists and is enumerable.
| Object | |
![]() |
Removes a listener from the EventDispatcher object.
| EventDispatcher | |
|
Reverts all pending (uncommitted) changes for all DataServices
managed by this DataStore.
| DataStore | ||
![]() |
Sets the availability of a dynamic property for loop operations.
| Object | |
![]() |
Returns the string representation of the specified object.
| Object | |
![]() |
Returns the primitive value of the specified object.
| Object | |
![]() |
Checks whether an event listener is registered with this EventDispatcher object or any of
its ancestors for the specified event type.
| EventDispatcher | |
| Event | Summary | Defined by | ||
|---|---|---|---|---|
| Dispatched when a conflict is detected between either pending changes on this client and changes submitted by another client, or when changes submitted by this client result detect a conflict error at the remote destination. | DataStore | |||
The FaultEvent.FAULT event is dispatched when the commit
call returns an error. | DataStore | |||
The ResultEvent.RESULT event is dispatched when the commit
call successfully returns. | DataStore | |||
| autoCommit | property |
autoCommit:Boolean [read-write]
If set to true, operations that modify the state managed by the
DataService are committed immediately. If set to false, you
must explicitly call the commit() method to send the changes to the server.
public function get autoCommit():Boolean
public function set autoCommit(value:Boolean):void
| autoMerge | property |
autoMerge:Boolean [read-write]
If set to false, when changes are pushed from the server to
the client they are not immediately applied. Instead, the
mergeRequired property is set to true. You can listen for
change events on this property to be notified of when a
merge needs to be applied. To merge changes, you call
the merge() method and all changes are applied.
You are not able to commit any changes when there are
any changes that must be merged.
public function get autoMerge():Boolean
public function set autoMerge(value:Boolean):void
| commitRequired | property |
commitRequired:Boolean [read-only]Indicates if there are pending updates that must be committed.
This property can be used as the source for data binding.
Implementation public function get commitRequired():Boolean
| conflicts | property |
conflicts:Conflicts [read-only]Returns a list of conflicts for all managed items.
This property can be used as the source for data binding.
Implementation public function get conflicts():Conflicts
| connected | property |
connected:Boolean [read-only]Indicates whether the DataStore is connected.
Implementation public function get connected():Boolean
| mergeRequired | property |
mergeRequired:Boolean [read-only]Indicates if there are any pending changes that must be merged.
This property can be used as the source for data binding.
Implementation public function get mergeRequired():Boolean
| requestTimeout | property |
requestTimeout:int [read-write]Provides access to the request timeout in seconds for an operation. A value less than or equal to zero prevents request timeout.
Implementation public function get requestTimeout():int
public function set requestTimeout(value:int):void
| DataStore | () | constructor |
public function DataStore(destination:String, useTransactions:Boolean)
Normally, a DataStore is created automatically for you but you
can create your own DataStore and assign it to the dataStore property
of a DataService. To do this, you must ensure all data services
that share the same data store use the same channel set and have
the same value of the use-transactions configuration setting.
Use this constructor to create a DataStore where the destination
parameter contains the destination of one of the DataServices using
this data store. This is just used to look up the channel set.
You also should provide the value for the use-transactions flag for
this data store.
destination:String |
|
useTransactions:Boolean |
| commit | () | method |
public function commit():AsyncToken
Commits any pending changes for all collections currently managed by
this DataService.
When the autoCommit property is true, transactions
are not be used.
To use transactions, set the autoCommit property to
false and call this method directly.
AsyncToken —
Object that is returned in call property of
either the ResultEvent.RESULT or in the
FaultEvent.FAULT.
Custom data can be attached to this object and inspected later
during the event handling phase.
|
| merge | () | method |
public function merge():voidMerges any pending updates into the managed set of objects. The process of merging changes can detect conflicts.
| revertChanges | () | method |
public function revertChanges():BooleanReverts all pending (uncommitted) changes for all DataServices managed by this DataStore.
ReturnsBoolean —
true if any changes were reverted.
|
| conflict | event |
mx.data.events.DataConflictEvent
mx.data.events.DataConflictEvent.CONFLICT
Dispatched when a conflict is detected between either pending changes on this client and changes submitted by another client, or when changes submitted by this client result detect a conflict error at the remote destination. The DataStore dispatches conflict events for all destinations which share the DataStore, or you can listen for conflict events for a specific type on a DataService. Use the DataStore when you have an object with associations as in that case, you may need to resolve conflicts in a specific order to maintain integrity of those associations.
The CONFLICT event type.
The properties of the event object have the following values:
| Property | Value |
|---|---|
bubbles | false |
cancelable | false |
currentTarget | The Object that defines the
event listener that handles the event. For example, if you use
myButton.addEventListener() to register an event listener,
myButton is the value of the currentTarget. |
conflict | The Conflict object that holds the conflict that occurred. |
message | The Message associated with this event. |
target | The Object that dispatched the event;
it is not always the Object listening for the event.
Use the currentTarget property to always access the
Object listening for the event. |
| fault | event |
mx.rpc.events.FaultEvent
mx.rpc.events.FaultEvent.FAULT
The FaultEvent.FAULT event is dispatched when the commit
call returns an error.
The FAULT event type.
The properties of the event object have the following values:
| Property | Value |
|---|---|
bubbles | false |
cancelable | true, calling preventDefault() from the associated token's responder.fault method will prevent the service or operation from dispatching this event |
currentTarget | The Object that defines the
event listener that handles the event. For example, if you use
myButton.addEventListener() to register an event listener,
myButton is the value of the currentTarget. |
fault | The Fault object that contains the details of what caused this event. |
message | The Message associated with this event. |
target | The Object that dispatched the event;
it is not always the Object listening for the event.
Use the currentTarget property to always access the
Object listening for the event. |
token | The token that represents the call to the method. Used in the asynchronous completion token pattern. |
| result | event |
mx.rpc.events.ResultEvent
mx.rpc.events.ResultEvent.RESULT
The ResultEvent.RESULT event is dispatched when the commit
call successfully returns.
The RESULT event type.
The properties of the event object have the following values:
| Property | Value |
|---|---|
bubbles | false |
cancelable | true, preventDefault() from the associated token's responder.result method will prevent the service or operation from dispatching this event |
currentTarget | The Object that defines the
event listener that handles the event. For example, if you use
myButton.addEventListener() to register an event listener,
myButton is the value of the currentTarget. |
message | The Message associated with this event. |
target | The Object that dispatched the event;
it is not always the Object listening for the event.
Use the currentTarget property to always access the
Object listening for the event. |
result | Result that the RPC call returns. |
token | The token that represents the indiviudal call to the method. Used in the asynchronous completion token pattern. |