fill( ) method
- Last Updated: January 17, 2024
- 10 minute read
- OpenEdge
- Version 12.8
- Documentation
Initializes JSDO memory with record objects from the data records in a single-table resource, or in one or more tables of a multi-table resource, as returned by the Read operation of the Data Object resource for which the JSDO is created.
This method also causes an offline or
online event to fire if it detects that there has been a
change in the JSDO login session's online state.
This method always executes asynchronously and returns results (either or both) in
subscribed JSDO event callbacks or in callbacks that you register using methods of a Promise
object returned as the method value. A Promise object is always returned as the method value
if jQuery Promises (or the exact equivalent) are supported in your development environment.
Otherwise, this method returns undefined.
Alias:
read( )
Return type: jQuery Promise or undefined
Applies to: progress.data.JSDO class
Working record: After completing execution, the working record for each JSDO table is set to its first record, depending on any active parent-child relationships (for a multi-table resource) and automatic sort settings. So, for each child table, the first record object is determined by its table reference sort order (if any) and its relationship to the related working record in its parent table.
Syntax
|
- parameter-object
- An
Objectinitialized with a set of properties that can be used on the server depending on a JSDO MappingType plugin that is both registered on the client and for which a corresponding Read operation is defined in the server Data Object. For more information on JSDO Mapping Type plugins and how to register and use them, see the description of the progress.data.PluginManager class.The JSDO also provides a built-in MappingType plugin named
"JFP"that can be used if the server Data Object is built to support it. This"JFP"plugin allows you to specify properties that can be used on the server to select, sort, and page the records to be returned. This built-in plugin supports any JSDO accessed by the JSDO dialect of the Kendo UI DataSource or any JSDO involved in data access. If you are using the JSDO dialect of the Kendo UI DataSource to bind a JSDO instance to Kendo UI widgets, the DataSource initializes and invokesfill( )with specific parameter-object properties that are defined based on the settings of the DataSourceserverPaging,serverFiltering, andserverSortingconfiguration properties. Also, if OpenEdge Data Objects are being accessed as external objects, as well as in calls to standard objects from Kendo UI,fill( )is invoked with similar parameter-object properties based on requirements.Note: Upon execution, thefill( )method immediately passes the parameter-object to arequestMapping( )function in the plugin to perform conversions.The
fill( )method further converts these parameter-object property settings to a format that is customized for each server Data Object resource, depending on its type. This format is then applied to the resource Read operation based on the presence of amappingTypeproperty set to"JFP"in the Data Service Catalog. For information on the requirements and the effects of using a"JFP"MappingType plugin for a Read operation in OpenEdge resources, see the topics on updating Business Entities for access by Kendo UI DataSources and external objects in OpenEdge Development: Web Services. For internal objects accessed using the JSDO, the requirements for using the built-in"JFP"MappingType plugin are managed internally by the server.The parameter-object properties required for the built-in
"JFP"MappingType plugin, which you can initialize when you callfill( )directly, include:filter— AnObjectcontaining property settings used to select the records to be returned. These property settings are in the same format as the property settings in the Kendo UI DataSourcefilterproperty object. For more information, see thefilterconfiguration property description in the Kendo UI DataSource documentation. The format that thefill( )method uses to pass this selection criteria to the server is specified, again, in the Data Service Catalog using themappingTypeproperty.If a
filterobject is not specified, the resource Read operation determines the records to return without selection criteria sent from the client.id— Astringspecifying a unique ID that the resource understands to identify a specific record.Note: This property is not currently used by the Kendo UI.skip— Anumberthat specifies how many records to skip before returning (up to) a page of data. You must specify this property together with thetopproperty.sort— An expression that specifies how to sort the records to be returned using one of the following formats:- An
Objectwith property settings in the same format as the property settings in the Kendo UI DataSourcesortproperty object. For more information, see thesortconfiguration property description in the Kendo UI DataSource documentation. - An
Arrayof strings in the same format as the sort-fields parameter of thesetSortFields( )method.
If this property is not specified, the resource Read operation determines the order of records to return without sort information sent from the client.
- An
tableRef— Astringspecifying the name of a table reference in the JSDO. This property is required when the JSDO represents a multi-table resource and thefilterpropertyObjectis also specified with filter information.top— Anumberthat specifies how many records (the page size) to return in a single page of data after usingskip. You must specify this property together with theskipproperty.Note: The final page of a larger result set can contain a smaller number of records thantopspecifies.
Note: You must specify bothskipandtopto implement server paging. For example, if you want to return the 5th page of data with a page size (top) of 10, setskipto 40. If these properties are not specified together, the resource Read operation determines the records to return without using any paging information sent from the client.Note: If you access the JSDO using only the JSDO dialect of the Kendo UI DataSource, the DataSource invokes thefill( )method with appropriate settings for these properties based on the corresponding Kendo UI settings. - filter-string
- This is a
stringcontaining selection criteria used by the Read operation as required by the resource:- For an OpenEdge resource — This is a
string that the resource defines for use on an OpenEdge application server to select
records to be returned, much like the
WHEREoption of the ABL record phrase. The actual format of this string and its affect on the records returned is determined by the ABL routine that implements the resource Read operation. For example, you might pass:- A single key value (e.g.,
"30") - A relational expression (e.g.,
"CustNum > 10 AND CustNum < 30") - An actual
WHEREstring (e.g.,'Item.CatDescription CONTAINS "ski & (gog* ! pol*)"')
Note: For an OpenEdge resource, the JSDO requires the URI for the Read operation of the resource to contain the following query string:"?filter=~{filter~}", where filter is the name of a string input parameter defined for the ABL routine that implements the operation (INPUTfilterAS CHARACTER).CAUTION: Using an actualWHEREstring for a dynamic ABL query can create a potential security issue. - A single key value (e.g.,
Note: If you want to use sorting or paging that your server Data Object resource supports, you must pass parameter-object instead of filter-string. - For an OpenEdge resource — This is a
string that the resource defines for use on an OpenEdge application server to select
records to be returned, much like the
If you do not pass either parameter-object or filter-string to this method, the records returned depend entirely on the Read operation that the resource implements.
Promise method callback signatures
jQuery Promise objects define methods that register a callback function
with a specific signature. The callback signatures depend on the method that returns the
Promise. Following are the signatures of callbacks registered by methods in any Promise
object that fill( ) returns:
Syntax:
|
- promise
- A reference to the Promise object that is returned as the value of the
fill( )method. For more information on Promises, see the notes on Promises in the description of the progress.data.JSDO class. - jsdo
- A reference to the JSDO that invoked the
fill( )method (Read operation) on its resource. For more information, see the description of the jsdo property of the request object. - success
- A
booleanthat istrueif the Read operation was successful. For more information, see the description of the success property of the request object.Note: It is not always necessary to test the value of success in a Promise method callback for thefill( )method, especially if the callback is registered usingpromise.done( )andpromise.fail( ), where the callback executes according to this value. - request
- A reference to the request object returned after the
fill( )method completed execution and returned any results from its Read operation on the server. For more information, see the description of the request object.
General operation
This method invokes the Read operation on the resource defined for the current JSDO. The result of calling this method replaces any prior data in JSDO memory with the record objects returned by this Read operation. The record objects are stored in one or more JSDO tables that correspond to the table or tables defined for the resource. If the JSDO is accessing multi-table resource (with one or more tables), such as an OpenEdge ProDataSet, and the resource supports before-imaging, the JSDO also updates the state of its JSDO memory with any before-image data sent with the loaded record objects, including any changes to record objects recorded in their before-image data.
saveChanges( ) method. Otherwise, the pending
changes will be lost when JSDO memory is initialized with records from the Read
operation.autoSort property, the record objects of each affected JSDO table reference are
sorted in JSDO memory according to the sort order you have established for the JSDO. If
sorting is done using sort fields, any string fields are
compared according to the value of the caseSensitive
property on a given table reference. If the autoSort
property setting is false for a given table reference, its
record objects are loaded in the order that they were serialized from the corresponding
resource table.Returning and handling results
This method returns results asynchronously in two different ways, and in the following order, depending on the development environment used to build the mobile app:
- Using JSDO named events for all environments — The following events fire before
and after the
fill( )method executes, respectively, with results handled by callback functions that you subscribe as documented for each event: - Using a Promise object returned for environments
that support jQuery Promises — Any callbacks that you register using Promise object
methods all execute both after the
fill( )method itself and after any subscribedafterFillevent callbacks complete execution. Note that the signatures of all Promise method callbacks match the signature of theafterFillevent callback function so you can specify an existingafterFillevent callback as the callback function that you register using any Promise method.
Because the callbacks that you register with any returned Promise methods execute only
after all subscribed afterFill event callbacks complete execution, you can
invoke logic in the Promise method callbacks to modify any processing done by the event
callbacks.
If the fill( ) method completes
successfully, the success parameter for any afterFill event callback or Promise method and the success property of each handler's request parameter object are both set to true, and any data records returned by the resource Read operation are loaded into
JSDO memory. Otherwise, both the success parameter and
success property are set to false, and you can read any error results by calling the getErrors( ) method on a single JSDO table reference, or by
inspecting the setting of the response property in the
same request parameter object.
fill( ) method does not return
an unsuccessful result in this case. If you need to identify before-image errors in records
returned by a Read operation, you can query the record objects in JSDO memory and call
getErrorString( ) on each record object to identify any such errors
that were returned.You can read any record objects loaded into JSDO memory by fill( ) using the find( ),
findById( ), foreach( ), and getData( ) methods of the JSDO.
You can return the schema for this data by using the getSchema( ) method. You can create a new record object in JSDO memory using the
JSDO add( ) method, and you can update or delete a single
record object in JSDO memory by using the assign( ) or
remove( ) method, respectively. You can display a record
in a UI form that you dynamically bind to the record by calling the display( ) method on a class instance. You can merge data returned by an
invocation method with the data in JSDO memory using the addRecords( ) method, and you can store and merge records in JSDO memory both to
and from a local storage location using the saveLocal( ),
readLocal( ), and addLocalRecords( ) methods.
Example
The following code fragment shows the fill( ) method invoked on a JSDO for an OpenEdge single-table resource
(dsCustomerOrder), with results returned using the
afterFill event:
|
Note that for an OpenEdge resource, the getErrors( ) method can return one or more error messages for a Read operation
in an array of error objects.
The following code fragment shows the fill( ) method invoked on a JSDO for a similar OpenEdge single-table
resource (dsCustomerOrder), with results returned using a
Promise object:
|
Using a Promise object, the Promise done and fail
functions do not have to test the success parameter for a successful
(true) or failed (false) execution of the fill( ) method, because done executes only
when fill( ) succeeds and fail
executes only when fill( ) fails.
The following code fragment shows the fill( ) method invoked on a JSDO for a resource (Orders), with results returned using a Promise object:
|
Any error results from a Read operation are returned by getErrors( ) as the single error type progress.data.JSDO.ERROR with the errors[idxError].error property set to a single returned string value.
See also:
autoSort property, caseSensitive property, getErrors( ) method, getId( ) method, invocation method, progress.data.PluginManager class, response property, saveChanges( ) method, setSortFields( ) method, success property