01.06.2013 Views

OpenEdge Development: Mobile Applications - Product ...

OpenEdge Development: Mobile Applications - Product ...

OpenEdge Development: Mobile Applications - Product ...

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 4: Creating <strong>Mobile</strong> Apps using JSDOs<br />

Methods of a JSDO and the JSRecord object<br />

Every JSDO has a number of methods, many of which interact with JSDO local<br />

storage. Some are called on the JSDO itself, while most are called on a JSDO table<br />

reference. Most execute synchronously, but some execute asynchronously as noted.<br />

For more information, see the “Asynchronous and synchronous execution” section on<br />

page 98. A few JSDO methods are also available on a JSRecord object.<br />

A JSDO includes methods for:<br />

• Executing built-in <strong>Mobile</strong> operations and calling their implementing AppServer<br />

routines:<br />

– fill( ) — Executes the read operation of a <strong>Mobile</strong> resource, loading the<br />

temp-table records sent from the AppServer into JSDO local storage<br />

according to the resource data model; the first record of every loaded<br />

temp-table reference is set as its working record.<br />

– saveChanges( ) — Executes the create, update, or delete operation of a<br />

<strong>Mobile</strong> resource for each record that has changed in JSDO local storage<br />

since the last execution of the fill( ) or saveChanges( ) method; no<br />

working records for any table references in local storage are set.<br />

These methods are always called on the JSDO and execute asynchronously.<br />

• Executing non-built-in <strong>Mobile</strong> invoke operations and calling their implementing<br />

AppServer routines. There is a uniquely named JSDO method defined for each<br />

invoke operation in the <strong>Mobile</strong> resource; these methods have no effect on JSDO<br />

local storage.<br />

These methods are always called on the JSDO and, by default, execute<br />

asynchronously, but can optionally execute synchronously. To pass input<br />

parameters to the implementing ABL routine, you pass an input object to the<br />

invocation method that contains properties with the values for any ABL input<br />

parameters. A property for an ABL input parameter has the same name (and letter<br />

case) as the corresponding input parameter, and has a JavaScript data type that<br />

maps to the ABL data type of the input parameter (see Appendix A, “ABL to<br />

JavaScript Data Type Mapping”)<br />

• Updating JSDO local storage:<br />

– add( ) — Called on a JSDO table reference, this method creates a new<br />

record object for the temp-table in JSDO local storage; the new record is set<br />

as the working record for the table reference.<br />

– addRecords( ) — Called either on a JSDO or on a JSDO table reference,<br />

this method updates JSDO local storage with record objects obtained from<br />

an object passed as a parameter to the method that follows the same<br />

schema as JSDO local storage; has no effect on existing working record<br />

settings.<br />

96 <strong>OpenEdge</strong> ® <strong>Development</strong>: <strong>Mobile</strong> <strong>Applications</strong>

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!