| Key points: |
- WebORB serializes a DataTable as an Array (or ArrayCollection). By default, each record in that array is serialized as an ActionScript object, with the record's properties being serialized as dynamic name/value pairs.
- It is often useful to serialize each record as an instance of given client-side class, instead of a dynamic object.
- Using the ReturnType attribute tells WebORB to serialize a DataTable's records as instances of a given client-side type.
- Server-side code:
- Line 6: 'using Weborb.Service' declares the ReturnType attribute
- Line 25: '[ReturnType("examples.weborb.Customer")]' tells WebORB to map all records in the following method's returned DataTable to instances of the client-side class, examples.weborb.Customer.
- 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-75: 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 result of the remote service call to CustomerService.getCustomers().
- main.mxml, line 41: binds the DataGrid's 'dataprovider' to 'customersAC', and hence to the result of the remote service call to CustomerService.getCustomers().
|