Adobe® Flex® 4 Language Reference
Hide Packages and Classes List |  Packages  |  Classes  |  Index  |  Appendixes
mx.data 
MessageBatch 
Packagemx.data
Classpublic class MessageBatch
InheritanceMessageBatch Inheritance EventDispatcher Inheritance Object
Implements IExternalizable

Language Version: ActionScript 3.0
Product Version: LiveCycle Data Services 3
Runtime Versions: Flash Player 9, AIR 1.1

Represents a group of changes: creates, updates, deletes, and update collection messages. There is always at least one open batch accessible via the DataStore.currentBatch property. Changes you make such as property changes detected automatically through data binding, createItem, updateItem, or deleteItem operations will be stored in this batch. The current list of uncommitted batches is stored in the uncommittedBatches property. You call createBatch create a new batch which is added to the end of the list. This batch is automatically made the currentBatch. You can commit or revert the set of a changes a batch at a time - in both cases, the batch is automatically removed from the uncommittedBatches list.

When there are dependencies between changes, you should commit and revert changes in order - i.e. commit the oldest batch in the list (uncommittedBatches[0]) and revert the most recent batch - uncommittedBatches[uncommittedBatches.length - 1].

The commitRequired property is set to true when there are any changes in the batch (i.e. items.length > 0). The items property stores the set of DataMessages in this batch.

You can store custom information in a MessageBatch via the properties property. Batches are saved/restored each time you use the saveCache method or automatically when autoSaveCache is true when using the offline feature.

Each batch also has a DataMessage associated with it in the batchMessage property. If you need to communicate information with the server (and you are sending the batch message to the server) you can store info in the headers of this message.



Public Properties
 PropertyDefined By
  batchMessage : DataMessage
This is the data message used to represent the batch being sent to the server If you need to pass additional per-transaction information you might use the headers of this message to communicate with your server code (assuming it actually sends the message instead of converting it on the client)
MessageBatch
  commitRequired : Boolean
[read-only] True if any changes are in this batch.
MessageBatch
 Inheritedconstructor : Object
A reference to the class object or constructor function for a given object instance.
Object
  properties : Object = null
An optional set of user defined properties you can set for this batch
MessageBatch
 Inheritedprototype : Object
[static] A reference to the prototype object of a class or function object.
Object
Public Methods
 MethodDefined By
  
Constructor.
MessageBatch
 Inherited
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
  
commit(itemsOrCollections:Array = null, cascadeCommit:Boolean = false):mx.rpc:AsyncToken
Commits the changes in the batch.
MessageBatch
 Inherited
Dispatches an event into the event flow.
EventDispatcher
  
Returns the message with the given id.
MessageBatch
 Inherited
Checks whether the EventDispatcher object has any listeners registered for a specific type of event.
EventDispatcher
 Inherited
Indicates whether an object has a specified property defined.
Object
 Inherited
Indicates whether an instance of the Object class is in the prototype chain of the object specified as the parameter.
Object
 Inherited
Indicates whether the specified property exists and is enumerable.
Object
  
This method de-serializes the message batch.
MessageBatch
 Inherited
removeEventListener(type:String, listener:Function, useCapture:Boolean = false):void
Removes a listener from the EventDispatcher object.
EventDispatcher
  
Removes the specified message from this batch.
MessageBatch
  
Reverts the changes for this batch - either all changes if no item is supplied - or just the changes for the specified item if it is supplied.
MessageBatch
  
Reverts the changes for all items in the specified managed collection.
MessageBatch
 Inherited
Sets the availability of a dynamic property for loop operations.
Object
 Inherited
Returns the string representation of this object, formatted according to locale-specific conventions.
Object
  
[override] Returns a String representation of this object.
MessageBatch
 Inherited
Returns the primitive value of the specified object.
Object
 Inherited
Checks whether an event listener is registered with this EventDispatcher object or any of its ancestors for the specified event type.
EventDispatcher
  
This method serializes the batch with the following stucture: numberOfElements:int - this is the total number of elements serialized [repeated element (once for every message in the batch)] destination:String - the destination of the associated DataService uid:String - the UID of the associated item message:DataMessage - the message for the associated change Because the message currently contains a copy of the item we don't have to serialize the message in a special way.
MessageBatch
Events
 Event Summary Defined By
 Inherited[broadcast event] Dispatched when the Flash Player or AIR application gains operating system focus and becomes active.EventDispatcher
 Inherited[broadcast event] Dispatched when the Flash Player or AIR application operating loses system focus and is becoming inactive.EventDispatcher
Public Constants
 ConstantDefined By
  items : ArrayCollection
This stores the list of MessageCacheItem instances which represent the changes in the batch.
MessageBatch
Property Detail

batchMessage

property
public var batchMessage:DataMessage

Language Version: ActionScript 3.0
Product Version: LiveCycle Data Services 3
Runtime Versions: Flash Player 9, AIR 1.1

This is the data message used to represent the batch being sent to the server If you need to pass additional per-transaction information you might use the headers of this message to communicate with your server code (assuming it actually sends the message instead of converting it on the client)

commitRequired

property 
commitRequired:Boolean  [read-only]

Language Version: ActionScript 3.0
Product Version: LiveCycle Data Services 3
Runtime Versions: Flash Player 9, AIR 1.1

True if any changes are in this batch. A bindable property.

This property can be used as the source for data binding. When this property is modified, it dispatches the propertyChange event.



Implementation
    public function get commitRequired():Boolean

properties

property 
public var properties:Object = null

An optional set of user defined properties you can set for this batch

Constructor Detail

MessageBatch

()Constructor
public function MessageBatch()

Language Version: ActionScript 3.0
Product Version: LiveCycle Data Services 3
Runtime Versions: Flash Player 9, AIR 1.1

Constructor.

Method Detail

commit

()method
public function commit(itemsOrCollections:Array = null, cascadeCommit:Boolean = false):mx.rpc:AsyncToken

Language Version: ActionScript 3.0
Product Version: LiveCycle Data Services 3
Runtime Versions: Flash Player 9, AIR 1.1

Commits the changes in the batch. Typically called with no arguments.

Parameters

itemsOrCollections:Array (default = null) — If you want to commit only some of the changes in the batch, you can commit changes for an item at a time or a collection of items at a time by setting the itemsOrCollections parameter.
 
cascadeCommit:Boolean (default = false) — Set to true to ensures that changes to associated items are also included in the commit.

Returns
mx.rpc:AsyncToken — AsyncToken reference to the token that will identify this operation in a result or fault event dispatched from this service.

getMessage

()method 
public function getMessage(messageId:String):DataMessage

Language Version: ActionScript 3.0
Product Version: LiveCycle Data Services 3
Runtime Versions: Flash Player 9, AIR 1.1

Returns the message with the given id. Returns null of no message with the given id exists in this batch.

Parameters

messageId:String — id of desired message.

Returns
DataMessage — the message with the given id. Returns null of no message with the given id exists in this batch.

readExternal

()method 
public function readExternal(input:IDataInput):void

Language Version: ActionScript 3.0
Product Version: LiveCycle Data Services 3
Runtime Versions: Flash Player 9, AIR 1.1

This method de-serializes the message batch. It expects the input byte stream to have the following structure: numberOfElements:int - this is the total number of elements serialized [repeated element (once for every message in the batch)] t] destination:String - the destination of the associated DataService uid:String - the UID of the associated item message:DataMessage - the message for the associated change

Parameters

input:IDataInput — input stream

removeMessage

()method 
public function removeMessage(msg:DataMessage):void

Language Version: ActionScript 3.0
Product Version: LiveCycle Data Services 3
Runtime Versions: Flash Player 9, AIR 1.1

Removes the specified message from this batch.

Parameters

msg:DataMessage — message to be removed.

revertChanges

()method 
public function revertChanges(item:IManaged = null):Boolean

Language Version: ActionScript 3.0
Product Version: LiveCycle Data Services 3
Runtime Versions: Flash Player 9, AIR 1.1

Reverts the changes for this batch - either all changes if no item is supplied - or just the changes for the specified item if it is supplied. You should typically only revert changes in the most recent batch as the system does not resolve or fix dependencies if you revert an older change which was depended upon by a later change.

Parameters

item:IManaged (default = null) — The item to revert.

Returns
Booleantrue if the revert completed successfully.

revertChangesForCollection

()method 
public function revertChangesForCollection(collection:ListCollectionView):Boolean

Language Version: ActionScript 3.0
Product Version: LiveCycle Data Services 3
Runtime Versions: Flash Player 9, AIR 1.1

Reverts the changes for all items in the specified managed collection.

Parameters

collection:ListCollectionView — The collection to revert.

Returns
Booleantrue if the revert completed successfully.

toString

()method 
override public function toString():String

Language Version: ActionScript 3.0
Product Version: LiveCycle Data Services 3
Runtime Versions: Flash Player 9, AIR 1.1

Returns a String representation of this object.

Returns
String — A String representation of this object.

writeExternal

()method 
public function writeExternal(output:IDataOutput):void

Language Version: ActionScript 3.0
Product Version: LiveCycle Data Services 3
Runtime Versions: Flash Player 9, AIR 1.1

This method serializes the batch with the following stucture: numberOfElements:int - this is the total number of elements serialized [repeated element (once for every message in the batch)] destination:String - the destination of the associated DataService uid:String - the UID of the associated item message:DataMessage - the message for the associated change Because the message currently contains a copy of the item we don't have to serialize the message in a special way.

Parameters

output:IDataOutput — object to write serialized bytes to.

Constant Detail

items

Constant
public const items:ArrayCollection

Language Version: ActionScript 3.0
Product Version: LiveCycle Data Services 3
Runtime Versions: Flash Player 9, AIR 1.1

This stores the list of MessageCacheItem instances which represent the changes in the batch. It is bindable so you can listen for change events on this collection to be notified of new changes.