RecordSet Object


The RecordSet object can be used with or without Flash Remoting MX. The object itself is a sophisticated array of objects that operates as a standard database query result set. A series of methods and properties are available to interact with the data inside the object. This is a standard ActionScript object that can be sent to a method or occupy a slot on a SharedObject. The server-side and client-side RecordSet objects are identical. On both platforms, you must manually load the RecordSet libraries to begin using them.

On the server, the RecordSet class is loaded automatically with the command:

 load("NetServices.asc"); 

On the client, the RecordSet class is loaded automatically with the command:

 #include "NetServices.as" 

To enable Code Hints and Code Completion in the Flash MX ActionScript Editor, use the suffix _rs in the name of the RecordSet variable.

Recordset Methods

RecordSet.addItem(record)

Inserts a new record into the RecordSet.

record

A Strict object containing name and value pairs with equivalent column names to the RecordSet. For example:

 my_rs.addItem = ({field1:"value",field2:"value"}); 
RecordSet.addItemAt(index, record)

Inserts a record at a precise row number. This overwrites any data that exists at that row number. Rows start at 0.

index The row number to add the item at.
record The Strict object to add. See the example in addItem.
RecordSet.filter(filterFunction, context)

Creates and calls a function that you create to query the RecordSet. The results populate a new RecordSet with references to the original RecordSet.

filterFunction A function that handles a single RecordSet record and a challenge value.
Context A value to challenge the RecordSet.
RecordSet.getColumnNames()

Returns a string list with the names of the columns (fields) of the RecordSet.

RecordSet.getItemAt(index)

Returns a record by row (index) number. The record is returned as an object with the columns as properties. For example: my_rs.getItemAt(5).myColumn; returns the value of the column myColumn at row 5. The single parameter is:

index The index (row) of the record to be retrieved.
RecordSet.getLength()

Returns the available length, or total number of records, of the RecordSet.

RecordSet.getNumberAvailable()

Returns the total length (or total number of records) of the RecordSet. This method returns the length reported by the application server before the records have arrived, accounting for slow network connections and large RecordSets.

RecordSet.removeAll()

Deletes all records from the RecordSet leaving an empty RecordSet, for which length equals 0.

RecordSet.removeItemAt(index)

Deletes a record from the RecordSet and locks the reuse of the index number.

index The record index (row) to be permanently deleted.
RecordSet.replaceItemAt(index, record)

Replaces a complete record that exists at an index value in the RecordSet.

index The record index (row) to be replaced .
record A Strict object containing name and value pairs with equivalent column names to the RecordSet. Review the addItemAt method for format.
RecordSet.setDeliveryMode = function(mode, pagesize, numPrefetchPages)

Sets the way in which Flash receives RecordSets from a Flash Remoting MX server. By default, it receives the entire RecordSet when it is ready. Setting a different mode affects how records will be requested and received. Use this function with the isFullyPopulated function to ensure the integrity of the RecordSet.

[mode] The RecordSet delivery method. The options are ondemand (default), fetchall , and page.
[pagesize] (Optional) Used in Page mode, it identifies what the size of the page is. In Fetchall mode, it identifies how many records to fetch in each server request.
[numPrefetchPages] (Optional) Used in Page mode, it identifies the number of pages to prefetch.
RecordSet.setField(index, fieldName, value)

Replaces the value of a single field within a RecordSet at a defined index.

index The index of the record containing the field to replace.
fieldname The name of the field (column) to update value.
value The new value to set in the field.
RecordSet. sort (compareFunction)

Sorts records within a RecordSet using a custom compare function:

compareFunction A custom comparison function.
RecordSet.sortItemsBy(fieldName, direction)

Sorts records within a RecordSet by field name. This will not make a duplicate copy of the RecordSet. The sorting key is the value or data within the field.

fieldname The name of the column (field) to sort by.
direction Two flag values: DESC sorts the fields by descending values, and ASC sorts the fields values by ascending .

RecordSet Properties

RecordSet.isFullyPopulated() returns a Boolean value. True indicates a fully populated RecordSet.

RecordSet.isLocal() returns a Boolean value. True means the RecordSet was created locally or from an application server.

RecordSet Event

RecordSet.addView(InfoObject) is invoked when a RecordSet is changed. This method receives an Information object (or event descriptor) that contains two parameters: event and description . Refer to the list of Information objects in Appendix C for a complete list of messages that can be received. This could be used to trigger a SharedObject broadcast.



Macromedia Flash Communication Server MX
Macromedia Flash Communication Server MX
ISBN: 0735713332
EAN: 2147483647
Year: 2002
Pages: 200
Authors: Kevin Towes

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net