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 3: Creating <strong>Mobile</strong> Services<br />

Coding ABL routines to implement a <strong>Mobile</strong> resource<br />

When you create a <strong>Mobile</strong> resource in Developer Studio (see the “Creating <strong>Mobile</strong><br />

resources” section on page 77), you can either create a new class to implement the<br />

resource using the New Business Entity wizard or you can use the Define Service<br />

Interface wizard to create the resource from an existing ABL class or external<br />

procedure coded to run as a singleton. Using these wizards, you can define ABL<br />

routines that provide the interface to one or more <strong>Mobile</strong> resources, each of which<br />

supports one or more <strong>Mobile</strong> operations.<br />

The two basic options that you must define for any class or procedure that implements<br />

a <strong>Mobile</strong> resource include the data model and the <strong>Mobile</strong> operations that the class or<br />

procedure supports. As described previously (see Chapter 1, “<strong>OpenEdge</strong> <strong>Mobile</strong><br />

Overview”), a <strong>Mobile</strong> resource can support a single data model that is managed by its<br />

built-in <strong>Mobile</strong> operations, create, read, update, and delete (CRUD). This data model<br />

can be the ABL definition for a single temp-table or a single ProDataSet that contains<br />

one or more temp-tables, including any data-relations defined for them. In the<br />

Developer Studio wizards, you select the data model from any temp-tables and<br />

ProDataSets that are defined in the class or procedure file, or in an external file that<br />

you specify. Once completed, the wizard, if directed, inserts the selected data definition<br />

in the main block of the class or procedure.<br />

Creating an ABL class with the New Business Entity wizard<br />

When you create a Business entity class to define the <strong>Mobile</strong> resource (using the New<br />

Business Entity wizard), it defines either a single <strong>Mobile</strong> read operation or a full set of<br />

<strong>Mobile</strong> CRUD operations for the selected data model. If the selected data model is a<br />

ProDataSet with multiple temp-tables, it also defines a separate invoke operation for<br />

each temp-table that is intended to read the table and return its data to a <strong>Mobile</strong> App<br />

as a JavaScript object.<br />

Each <strong>Mobile</strong> CRUD operation is defined by a single VOID ABL method whose name<br />

consists of a concatenation of the operation name with the name of the resource data<br />

model instance, has an empty code block, and has a parameter list that is tailored to<br />

reference the selected data model. The exact parameter list for each method is<br />

prescribed by the <strong>Mobile</strong> operation that it implements. For example, if the data for the<br />

resource is a ProDataSet named dsCustomer and the read operation is being defined,<br />

the method name is created as ReaddsCustomer. You must then add the code for each<br />

<strong>Mobile</strong> CRUD operation to implement each operation according to <strong>OpenEdge</strong> <strong>Mobile</strong><br />

functional requirements. For more information, see the “Coding the ABL for <strong>Mobile</strong><br />

operations” section on page 71.<br />

In addition, when the wizard is directed to generate a <strong>Mobile</strong> interface, both the first<br />

ABL statement in the file and each METHOD statement in the class are preceded by a<br />

set of annotations that start with the '@' character and specify how the class and each<br />

method is to be accessed and executed as a <strong>Mobile</strong> resource and operation.<br />

Caution: Do not modify the annotations in the ABL source file for a <strong>Mobile</strong> resource.<br />

Doing so can make the resource inaccessible from a <strong>Mobile</strong> App or otherwise<br />

fail to function.<br />

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