Main Page | Packages | Class Tree | Index | Help

xp.data

class DataSource

Object
  |
  +--xp.system.DispatcherObject
        |
        +--xp.data.ItemDataSource
              |
              +--xp.data.DataSource

All Known Subclasses: ListDataSource

class DataSource
extends ItemDataSource

DataSource objects lets you work with data.

DataSource encapsulates a single data object exposed though the currentItem property.
DataSource adds the capabilty to update, insert and delete the current item, track the changes to the currrentItem through a DeltaPacket that can be used to update the server. SubClasses like ListDataSource lets you work with data as collections of objects.
A DataSource can be bound to the currentItem of another DataSource or a ListDataSource to create simple master/detail relationships.
A DataSource is somewhat similar to a DataHolder.

Event summary for the ListDataSource class
The following table lists events of the ListDataSource class.









EventTypeDescription
xp.events.ModelChangedEventmodeChangedBroadcast when the data model changes.
xp.events.EventloadBroadcast after the list has loaded.
xp.events.EventinsertItemBroadcast before inserting the current item.
xp.events.EventupdateItemBroadcast before editing the current item.
xp.events.EventdeleteItemBroadcast before deleting the current item.
xp.events.EventapplyChangesBroadcast before row item changes are applied and the DS if uses manual changes.
xp.events.EventvalidateChangesBroadcast before row item changes are applied nad need to be validated. You can accept, amend or reject the changes in you own validation routines
xp.events.ItemEventnewItemBroadcast when a new item is created.
xp.events.ItemEventcalcFieldsBroadcast when the calculated fields need refreshing.


Author:
ProWin Computers Ltd. - Rob Edgar

Version:
3.0.0.000

See also:


Field Summary

public
autoCommit: Boolean
Control whether changes are automatically commited when validated.

public
autoEdit: Boolean
Control whether the datasource can automatically enter edit mode

public
autoInsert: Boolean
Control whether the datasource can automatically enter insert mode

public
calcFields: Object
The names of the calculated fields.

public static
classInfo: Object
A static class information object

public
deltaPacket: Object
Returns changes made to the collection, or assigns changes to be made to the collection

public
itemClassName: Function
The class for new data items

public
logChanges: Boolean
Indicates whether changes made to the collection, or its items, are recorded.

public
newDataItem: Object
A new data item

public
nodeName: String
The node name for new xml data items

public
usesManualCommit: Boolean
Control whether this source uses manual commits for row changes

Fields inherited from class xp.data.ItemDataSource

classInfo, dataSourceBinding, id, name, readOnly

Fields inherited from class xp.system.DispatcherObject

parent

Property Summary

public
currentItem: Object (read-only)
Get the current data item encapsulated by this datasource

public
isEditing: Boolean (read-only)
Is the current record being edited

public
isInserting: Boolean (read-only)
Is the current record being insertd

public
isValid: Boolean (read-only)
Is the current row valid

public
schema: Object (read, write)
Get or set the schema.

Properties inherited from class xp.data.ItemDataSource

currentItem, data, isEmpty, length

Constructor

public
DataSource ( dataItem: Object)
Create a new DataSource instance

Method Summary

public
applyChanges ( ): Boolean
Save or commit current item edits

public
applyUpdates ( ): Void
Signals that the deltaPacket property has a value that you can access using data binding or ActionScript

public
cancelChanges ( ): Boolean
Rollback changes to the current item

public
checkSchema ( force: Boolean ): Void
Check whether the schema has been created

public
commitChanges ( ): Void
Commit's changes for the current transaction

public
createItem ( ): Object
create a new item

public
deleteItem ( ): Boolean
Deletes the current item

public
editItem ( ): Boolean
Switch to edit mode

public
getClass ( ): Function
Returns a reference to the components static class

public
insertItem ( ): Boolean
Switch to insert mode

public
rollbackChanges ( ): Void
Rollsback changes for the current transaction

public
toString ( ): String
the info

public
validate ( ): Boolean
Validates the current record

Methods inherited from class xp.data.ItemDataSource

addBinding, getBinding, getClass, refresh, updateViews

Methods inherited from class xp.system.DispatcherObject

addEventListener, removeEventListener, routeEvent



Field Documentation

autoCommit

public var autoCommit: Boolean
Control whether changes are automatically commited when validated.

If false a row may be validated but remain dirty.

autoEdit

public var autoEdit: Boolean
Control whether the datasource can automatically enter edit mode

If true then any attempt to edit data in a field will place the datasource in edit mode

autoInsert

public var autoInsert: Boolean
Control whether the datasource can automatically enter insert mode

If true then any attempt to edit data in a field when there is not currentItem will place the datasource in insert mode

calcFields

public var calcFields: Object
The names of the calculated fields.

A space separated list of calculated fields.
This property only needs to be set if you have calculated fields AND you have not explicilty set the schema.
Calculated fields will still function even if this property is not set, however whilst editing or inserting calculated fields may not update until the record is committed.
If a schema has been set then this property is ignored

classInfo

public static var classInfo: Object
A static class information object

Every class has an associated classInfo object that holds the version and other static information. The classInfo can be accessed either directly by referencing the static class or by calling getClass() on any class instance.

deltaPacket

public var deltaPacket: Object
Returns changes made to the collection, or assigns changes to be made to the collection

Property; returns a delta packet that contains all of the change operations made to the dataSource collection and its items. This property is null until DataSource.applyUpdates() is called on dataSource. When DataSet.applyUpdates() is called, a transaction ID is assigned to the delta packet. This transaction ID is used to identify the delta packet on an update round trip from the server and back to the client. Any subsequent assignment to the deltaPacket property by a delta packet with a matching transaction ID is assumed to be the server’s response to the changes previously sent. A delta packet with a matching ID is used to update the collection and report errors specified within the packet.

itemClassName

public var itemClassName: Function
The class for new data items

This is used to generate a new object when createItem is called

logChanges

public var logChanges: Boolean
Indicates whether changes made to the collection, or its items, are recorded.

A Boolean value that specifies whether changes made to the data source, or its items, should (true) or should not (false) be recorded in DataSource.deltaPacket. When this property is set to true, operations performed at the collection level and item level are logged. Collection-level changes include the addition and removal of items from the collection. Item-level changes include property changes made to items and method calls made on items by means of the DataSource component.

newDataItem

public var newDataItem: Object
A new data item

This is used as a template when createItem is called

nodeName

public var nodeName: String
The node name for new xml data items

This is used to generate a new XMLNode when createItem is called

usesManualCommit

public var usesManualCommit: Boolean
Control whether this source uses manual commits for row changes


Property Documentation

currentItem

public currentItem: Object (read-only)
Get the current data item encapsulated by this datasource

Overrides:

isEditing

public isEditing: Boolean (read-only)
Is the current record being edited

isInserting

public isInserting: Boolean (read-only)
Is the current record being insertd

isValid

public isValid: Boolean (read-only)
Is the current row valid

schema

public schema: Object (read, write)
Get or set the schema.

Schema is optional and only used when logging changes.


Constructor Documentation

DataSource

public function DataSource(dataItem: Object)
Create a new DataSource instance


Method Documentation

applyChanges

public function applyChanges(): Boolean
Save or commit current item edits

Returns:
True if the changes were saved otherwise false

applyUpdates

public function applyUpdates(): Void
Signals that the deltaPacket property has a value that you can access using data binding or ActionScript

Signals that the DataSource.deltaPacket property has a value that you can access using data binding or directly by ActionScript. Before this method is called, the DataSource.deltaPacket property is null. This method has no effect if events have been disabled by means of the DataSource.disableEvents property Calling this method also creates a transaction ID for the current DataSource.deltaPacket property and emits a deltaPacketChanged event. For more information, see DataSource.deltaPacket

cancelChanges

public function cancelChanges(): Boolean
Rollback changes to the current item

This method can be called during editing or inserting to cancel any current changes and rollback to the previous version.

Returns:
Boolean indicating whether the datasource rolledback sucesfully

checkSchema

public function checkSchema(force: Boolean): Void
Check whether the schema has been created

If logChanges is true and no schema exists a default schema will be generated. This will also result in the dataItem object being built.

Parameters:
force
If true forces logChanges to be true

commitChanges

public function commitChanges(): Void
Commit's changes for the current transaction

createItem

public function createItem(): Object
create a new item

Creates a new data item but does not insert it or add it to the collection. The newItem event will be fired allowing the user to modify the data itme before it is returned This is called internally when insertItem is called to place the DataSource in insert mode The property newDataItem is used as the template for the empty data item.

Returns:
The new data item.

deleteItem

public function deleteItem(): Boolean
Deletes the current item

Returns:
Boolean indicating whether the datasource deleted the item

editItem

public function editItem(): Boolean
Switch to edit mode

Returns:
Boolean indicating whether the datasource changed to the requested mode

getClass

public function getClass(): Function
Returns a reference to the components static class

Overrides:

insertItem

public function insertItem(): Boolean
Switch to insert mode

Returns:
Boolean indicating whether the datasource changed to the requested mode

rollbackChanges

public function rollbackChanges(): Void
Rollsback changes for the current transaction

toString

public function toString(): String
the info

validate

public function validate(): Boolean
Validates the current record

Check whether the current record is valid or not. If autoCommit is true it implicitly calls applyChanges if the current record is not valid

Returns:
True if the current record is valid


The documentation was generated from the following file:


Generated on 10/30/2005 9:34:02 PM by AS2Doc