OpenEdge Development: Mobile Applications - Product ...
OpenEdge Development: Mobile Applications - Product ...
OpenEdge Development: Mobile Applications - Product ...
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
Creating a JSDO for a <strong>Mobile</strong> resource<br />
Creating a JSDO for a <strong>Mobile</strong> resource<br />
The following code fragment shows a simple JavaScript coding sequence for creating<br />
a JSDO, starting the attempted login of the user:<br />
// create Session and set it for HTTP Basic Authentication<br />
var pdsession = new progress.data.Session();<br />
pdsession:authenticationModel = progress.data.Session.AUTH_TYPE_BASIC;<br />
// log in, i.e., authenticate to the <strong>Mobile</strong> Web application<br />
pdsession.login('/Sports<strong>Mobile</strong>', username, password);<br />
if pdsession.loginResult == progress.data.Session.LOGIN_SUCCESS {<br />
}<br />
// load catalog for a service that's part of the <strong>Mobile</strong> Web application<br />
pdsession.addCatalog('/Sports<strong>Mobile</strong>/static/mobile/Sports<strong>Mobile</strong>Svc.json');<br />
// create JSDO<br />
var dsCustomer = new progress.data.JSDO({<br />
name : 'dsCustomer',<br />
autoFill : true,<br />
events : {<br />
'afterFill' :<br />
[ {<br />
scope : this,<br />
fn : function (jsdo, success, request) {<br />
// afterFill event handler statements ...<br />
}<br />
} ]<br />
}<br />
});<br />
// JSDO access continues ...<br />
// Login error begins ...<br />
The fragment shows the setting of the authenticationModel property on the Session<br />
object, pdsession, to code for the Web server HTTP Basic Authentication model for<br />
which the <strong>Mobile</strong> Web application is configured. After logging into the <strong>Mobile</strong> Web<br />
application with its relative URI, /Sports<strong>Mobile</strong>, the code tests for the success of the<br />
login, and for a positive test, immediately loads the JSDO catalog for the<br />
Sports<strong>Mobile</strong>Svc service.<br />
It then instantiates a JSDO using an initialization object passed to the constructor,<br />
which specifies the:<br />
• <strong>Mobile</strong> resource, dsCustomer<br />
• Setting of the initialization property, autoFill, to invoke the fill( ) method<br />
upon instantiation<br />
• Subscription of an in-line function to the afterFill event to check the results of<br />
the fill( ) method<br />
<strong>OpenEdge</strong> ® <strong>Development</strong>: <strong>Mobile</strong> <strong>Applications</strong> 105