Accessibility

Table of Contents

Binding ColdFusion data to Flex UI components with Adobe Flash Builder 4 beta

Configuring the data return type

As mentioned in the introduction, this tutorial uses the same development environment as Getting started with ColdFusion and Flash Builder 4 beta and the other tutorials in this series. In this section, you will name a second data type for use with a different service call to a CFC function:

  1. Locate the Data/Services view in Flash Builder 4 beta. You should see the F4CF_Getting_Started_Service service shown in Figure 1.

    Verify whether the EmployeeSalesData data type has been defined.

    Figure 1. Verify whether the EmployeeSalesData data type has been defined.

  2. In the Data/Services view, right-click the getEmployeeDataByRegion() function of the F4CF_Getting_Started_Service service and select Configure Return Type (see Figure 2).

    Configuring the return type of a CFC method

    Figure 2. Configure the return type of a CFC method.

    Each record from the query will be placed in an ActionScript object with each column of data (FIRSTNAME, LASTNAME, EMAIL, and so on) set in a name/value pair. Each record is indexed starting at zero.

    Note: Unlike ColdFusion, ActionScript is a zero-indexed language.

    Rather than generically referring to the returned data as an object, the wizard lets you to give the data a return type name. You will do this next.

  3. In the Configure Operation Return Type dialog box, create a new custom data type named EmployeeDataByRegion (see Figure 3).

    Note: This data type differs from the EmployeeSalesData data type defined in the Getting started with ColdFusion and Flash Builder 4 beta tutorial because this one requires that you supply an argument, named region, to limit the data being returned to employees in a specific region. It also returns fewer columns of data from the database.

    Create a new custom data type.

    Figure 3. Create a new custom data type.

  4. Click Next.
  5. In the Create New Data type dialog box, in the Enter Value column, type Central (see Figure 4).

    Enter a region value.

    Figure 4. Enter a region value.

    You must enter an argument value of Central to return the query results. This is just a mechanism to demonstrate that the query is working correctly so that you can define the return type name for it. In later steps, you will change the code to actually pass the argument value in the application.

  6. Click the Yes option to specify that the operation needs remoting credentials.
  7. Enter your username and password in the Remote Service Authentication window (see Figure 5).

    Entering the remoting credentials for the
getEmployeeData() CFC function

    Figure 5. Enter the remoting credentials for the getEmployeeData() CFC function.

  8. Click OK.
  9. Click Next.
  10. Review the Modify Properties of Return Type dialog and click Finish.

You will see the EmployeeSalesDataByRegion data type listed in the Data Types category of the Data/Services view as shown in Figure 6. Note that the properties of the data type are the query columns returned from the CFC method.

Figure 6. Note the data type and its properties.

The data returned from the CFC contains employee information associated with a region: Northwest, Southwest, Central, Northeast, and Southeast. See Deploying a Flex application with ColdFusion URL variables to learn more about passing dynamic data to an application. In this tutorial, you will hard-code the region value.