OpenEdge Development: Mobile Applications - Product ...
OpenEdge Development: Mobile Applications - Product ...
OpenEdge Development: Mobile Applications - Product ...
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
Chapter 4: Creating <strong>Mobile</strong> Apps using JSDOs<br />
For a non-built-in invoke operation that completes successfully, the response property<br />
references an object that contains properties with the values of any output parameters<br />
and return value returned by the ABL routine. A property for an ABL output parameter<br />
has the same name (and letter case) as the corresponding output parameter, and has<br />
a JavaScript data type that maps to the ABL data type of the output parameter (see<br />
Appendix A, “ABL to JavaScript Data Type Mapping”). Any return value from the<br />
routine is returned as the <strong>OpenEdge</strong>-defined property, _retVal, also with a<br />
ABL-mapped JavaScript data type.<br />
For a <strong>Mobile</strong> operation that completes with one or more ABL errors, the response<br />
property references an object that contains two <strong>OpenEdge</strong>-defined properties:<br />
• _retVal — A String with the value of any ABL RETURN ERROR string or<br />
ReturnValue property for a thrown AppError object<br />
• _errors — An array of JavaScript objects, each of which contains properties with<br />
the ABL error message string and error number for one of possibly many<br />
ABL-returned errors.<br />
Note: In the current <strong>OpenEdge</strong> release, this array always returns one object only<br />
for the first ABL error (the equivalent of ERROR-STATUS:GET-MESSAGE(1) in<br />
ABL).<br />
For more information on the request object and its available properties, see its<br />
reference entry in Appendix B, “<strong>OpenEdge</strong> JavaScript Class and Object Reference”.<br />
General error handling for <strong>Mobile</strong> operations<br />
For any <strong>Mobile</strong> operation that completes with an error of any kind (ABL, <strong>Mobile</strong> Web<br />
application, or network), the success property of the returned request object (and the<br />
success parameter of the event handler) is set to false. As noted in the previous<br />
section, any ABL errors can be found in the object returned by the response property.<br />
All other Web application and network errors can be inspected using the xhr property<br />
of the request object. For more information on the XMLHttpRequest object that this<br />
property references, see the software development documentation for your Web<br />
browser or mobile device.<br />
Note that for a <strong>Mobile</strong> create, update, or delete operation, if any error, at any point<br />
causes the operation to complete unsuccessfully, the record in JSDO local storage is<br />
reverted prior to any change that caused the operation to be executed. So, for example,<br />
a failed create operation causes the added record to be removed from local storage.<br />
The record object that was originally added for the operation is then available for your<br />
re-use as the jsrecord property of the request object (or the record parameter if the<br />
event handler). A similar reversion occurs for the update and delete operations, with<br />
the field values of any updated record reverted to their original values, and any deleted<br />
record added back to local storage.<br />
Properties of a JSDO<br />
Every JSDO has several properties to manage its state. We have already introduced<br />
the table reference properties that provide access to temp-table data loaded into JSDO<br />
local storage, and the record property, which provides access to individual record<br />
objects on a given table reference (see the “How JSDO local storage works” section on<br />
page 93).<br />
102 <strong>OpenEdge</strong> ® <strong>Development</strong>: <strong>Mobile</strong> <strong>Applications</strong>