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.

afterUpdate event<br />

Example:<br />

/* subscribe to event */<br />

myjsdo.subscribe('afterUpdate', onAfterUpdate);<br />

/* some code that would update a record and send to the server */<br />

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

myjsdo.assign( updatedDataObject );<br />

myjsdo.saveChanges();<br />

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

if (success) {<br />

/* for example, get the values updated by the server from the record<br />

to redisplay */<br />

var newValue = record.data.myField;<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 />

See also: assign( ) method (JSDO class), subscribe( ) method, unsubscribe( )<br />

method<br />

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