RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
TDataSetAdapter Class

TDataSetAdapter defines a scriptable interface to a TDataSet component and allows it to operate properly in a stateless environment.

Pascal
TDataSetAdapter = class(TCustomDataSetAdapter);
C++
class TDataSetAdapter : public TCustomDataSetAdapter;

Use TDataSetAdapter like TAdapter to define a custom interface to application logic. (See TAdapter for a general description of Adapters.) Add adapter field components to the TDataSetAdapter to define the dataset fields that a script can access. Set properties of the adapter field components to augment the meta data provided by the dataset fields. For example, the ValuesList property defines name/value pairs that can be used to populate HTML elements for editing the field such as select lists and radio buttons. If you do not add any adapter fields, all adapter fields for all supported dataset field types are added by default. Default adapter fields are not shown in the object tree view but can be accessed with script and will be used when generating a form or grid with the TAdapterPageProducer. 

Add adapter action components to the TDataSetAdapter to define the commands that can be executed on the dataset. TDataSetAdapter has built-in support for commands such as Delete, Next Row, and Edit. If you do not add any adapter actions, all actions are added by default. Default adapter actions are not shown in the object tree view but can be accessed with script and will be used when generating a form or grid with the TAdapterPageProducer. 

The TDataSetAdapter has a mode. The mode values include Edit, Insert, Browse, and Query. The mode of the TDataSetAdapter will affect the adapter field values retrieved by script statements. The mode may also affect the HTML generated by the TAdapterPageProducer component. For example, a form field will be displayed using an input element when in Edit, Insert, or Query mode but displayed as read-only text when in Browse mode. The TDataSetAdapter mode is modified during the execution of adapter action components such as TDataSetAdapterEditRowAction. The mode can also be modified using server side script (for example; <% Adapter.Mode = 'Edit' %>). To cause the TAdapterPageProducer to generate script to modify the mode, change the AdapterMode property of a TAdapterFieldGroup component. 

The TDataSetAdapter supports master/detail relationships between datasets. You must associate a TDataSetAdapter with each master and detail dataset and use the MasterAdapter property to indicate the master/detail relationship between the TDataSetAdapter components. 

In a WebSnap application there is no guarantee that the same web module will be used to service consecutive requests from the same user. The TDataSetAdapter manages the state of the dataset component to ensure data integrity. TDataSetAdapter responsibilities include opening and closing the dataset, locating records, validating edits, posting changes, canceling changes, and handling exceptions. 

 

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!