You are here: Recent News » Documentation Pages List » AMF - ActionScript Message Format » Recordsets

 

Recordsets

Remoting recordsets are sent back from the server as a typed object (type 0x0A). They are then mapped locally in the Flex framework as mx.remoting.Recordset. Flash recordsets are specifically targeted at holding SQL records. Recordsets have a built-in paging functionality that gateways may wish to implement.

Recordset structure

All recordsets sent back from the server should start as a typed object (0x0A) with name ‘RecordSet’ (note camel-case). This object contains only one element with key: ‘serverInfo’. The value of serverInfo should be an object (0×03) with the following elements:

Key name Value
totalCount The total number of records in the recordset, as a Number
initialData The recordset data as an array (see below)
cursor 1
serviceName If gateway implements pageable recordsets, the name of the service that retrieves further records in the recordset
columnNames The column names, as an array of strings.
version 1
id A recordset id, only used if array is recordset is paged

initialData

initialData should be an array of arrays containing the recordset data. Only numeric keys are used, as the columnNames are encoded separately. An inner array is a single row of data. The inner data may be of any reasonable single-level type, such as string, boolean, Number, etc. Setting a cell to an array or object will work but should be reserved for special applications.

Pageable recordset mechanism

If the number of rows in the initialData is less than the totalCount key, and the serviceName is set, Flash identifies the recordset as pageable. When an unretrieved row is looked up, Flash detects the absence and calls a special service; it retrieves the name of this service from the ‘serviceName’ key. While the server determines the initial amount of rows sent back, the client determines the amount of data sent back on subsequent calls through the mx.remoting.RecordSet :: setDeliveryMode function.

Pageable recordset request

The ‘getRecords’ method of the paging service is called with three arguments:

  • Recordset id (the same as the ‘id’ key in the original recordset)
  • Offset (1-based)
  • Number of records to retrieve

With the recordset id, the service may use a variety of mechanism to reconstruct the recordset; typically the original recordset will be stored in a session variable, or perhaps the arguments originally sent to the method are stored to recreate a LIMIT statement. Implementation is left to the gateway.

Pageable recordset answer

The pageable recordset request should be answered by a typed object (0x0A) with class name ‘RecordSetPage’. This object should contain the ‘Cursor’ key and the ‘Page’ key (note caps). The cursor should be be set to the same number as the requested offset. The page should contain an array of arrays containing the requested data. The column names are not sent back in this request as they are stored locally by Flash.

documentation/amf/recordset.txt · Last modified: 2007/11/07 13:53 by thijs