01.06.2013 Views

OpenEdge Development: Mobile Applications - Product ...

OpenEdge Development: Mobile Applications - Product ...

OpenEdge Development: Mobile Applications - Product ...

SHOW MORE
SHOW LESS

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 />

When the operation is complete, any working record for an associated temp-table and<br />

for any child temp-tables is not set.<br />

When you call saveChanges( ) to synchronize changes made by this method with the<br />

database, the AppServer executes the ABL routine that is associated in the JSDO<br />

catalog with the delete operation.<br />

Note: If an error occurs on the server, the record is automatically restored in the<br />

JSDO’s local storage.<br />

Associated ABL routine: Delete<br />

The signature of the ABL routine associated with a delete operation must have a<br />

DATASET or TEMP-TABLE INPUT-OUTPUT parameter.<br />

The following example shows a DeleteOrderEntry( ) method that might be<br />

associated with <strong>Mobile</strong> delete operations:<br />

METHOD PUBLIC VOID DeleteOrderEntry(INPUT-OUTPUT DATASET dsOrderEntry):<br />

END METHOD.<br />

Client JavaScript code: Delete<br />

The following example illustrates calling remove( ) on a JSRecord object:<br />

/* subscribe to event */<br />

dsOrderEntry.subscribe('afterDelete', onAfterDelete);<br />

var jsrecord = dsOrderEntry.ttCustomer.findById(myid);<br />

jsrecord.remove();<br />

dsOrderEntry.saveChanges();<br />

function onAfterDelete (jsdo , record , success , request ) {<br />

if (success) {<br />

/* for example, get the values from the record that was<br />

deleted to display a confirmation message */<br />

var myKeyField = record.data.myKeyField;<br />

<br />

}<br />

else {<br />

if (request.response && request.response._errors &&<br />

request.response._errors.length > 0){<br />

var lenErrors = request.response._errors.length;<br />

for (var idxError=0; idxError < lenErrors; idxError++) {<br />

var errorEntry = request.response._errors[idxError];<br />

var errorMsg = errorEntry._errorMsg;<br />

var errorNum = errorEntry._errorNum;<br />

/* handle error */<br />

}<br />

}<br />

}<br />

};<br />

112 <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!