| Key points: |
- WebORB serializes a DataSet to the Flex client as an instance of the dynamic ActionScript class Object. Each of the DataSet's DataTables is stored in dynamic properties named Table1, Table2, Table3, etc.
- WebORB serializes each DataTable in a DataSet as an Array (or ArrayCollection). By default, each record in each array is serialized to an ActionScript object, with the record's properties being mapped to dynamic name/value pairs.
- It is often useful to map each record to an instance of given client-side class, instead of a dynamic object.
- Using the ReturnType attribute tells WebORB to serialize a DataSet's DataTables' records as instances of a given client-side type.
- Server-side code:
- Line 6: 'using Weborb.Service' declares the ReturnType attribute
- Line 45-57: Defines the returnsNull() method, which serves no purpose other than to tell WebORB that its code generator should generate a client-side Data Transfer Object class for this server-side class. The ReturnType attribute, above, refers to this WewbORB-generated Data Transfer Object class.
- Line 61: '[ReturnType("examples.weborb.Customer")]' tells WebORB to map all records in the following method's returned DataSet's DataTables to instances of the client-side class, examples.weborb.Customer.
- Line 73-87: Defines the server-side Customer class mentioned above.
- Client-side code:
- examples.weborb.vo.Customer.as: Defines the Data Transfer Object class generated by WebORB from the server-side Customer class, as described above.
- main.mxml, lines 31-32: defines customersAC, an ArrayCollection, and binds its 'source' to the dynamic property Table1 in the object that is the result of the remote service call to CustomerService.getCustomersAsDataSet().
- main.mxml, line 41: binds the DataGrid's 'dataprovider' to 'customersAC', and hence to the result of the remote service call.
|