User Guide
48 Using the Flex Data Service Assembler
Example application
This section describes creating a Flex application that uses the ColdFusion Data Service
adapter and Flex Data Service assembler so that a ColdFusion component handles the back-
end database management.
You can download the source code for the files that are included in the Flex sample Contact
application from “Using ColdFusion with Flex – Part 1: Creating and Running a Contact
Manager Application.” In addition, you can view the code for the Flex sample Contact
appliation in “The Flex Contact Manager Application” on page 62.
To use ColdFusion instead of the Java adapter:
1. Create the assembler CFC.
2. Create the DAO CFC.
3. Create the Value Object CFC.
4. Specify the destination in the data-management-config.xml file.
5. Copy the files for the Flex Contact sample application to the appropriate folders.
6. Run the application.
Creating the assembler CFC
The assembler CFC contains the fill, sync, get, and count methods.
Creating the fill method
In the Contact sample application, the fill operation has two forms: one that takes no
argument, and one that takes a string. The corresponding Java function returns a List of
Contact objects. Because a List corresponds to an array in ColdFusion, the
fill method
returns an array of Contact objects. The
fill method appears as follows:
<cffunction name="fill" output="no" returntype="samples.contact.Contact[]"
access="remote">
<cfargument name="param" type="string" required="no">
<cfset var ret = ArrayNew(1)>
<cftry>
<cfset dao = CreateObject("component","samples.contact.ContactDAO")>
NOTE
To make creating the CFCs easier, ColdFusion MX 7.0.2 includes wizards that you
can use in Flex Builder. For more information, see Chapter 5, “Using the ColdFusion
Extensions for Flex Builder”.