Adobe ColdFusion 8

Configuring a destination for the ColdFusion Data Service adapter

To provide the information necessary for the Flex application to connect to the ColdFusion back-end application, you configure a destination. In the destination, you specify the ColdFusion Data Service adapter, the channels to use to transport messages to and from the destination, the CFC that contains the fill, get, sync, and count methods, and other settings.

To provide configuration information, you edit the following files:

  1. services-config.xml

    You specify channel definitions and enable ColdFusion-specific debugging output in the Flex console in this file. You must also change the port numbers in the services-config.xml file for the RTMP channels if you run more than one ColdFusion instance with the integrated LiveCycle Data Services ES.

  2. data-management-config.xml

    You specify adapters and destinations in this file.

To ensure that Flex recognizes the LiveCycle Data Services ES assembler and can transport messages to and from the destination, by doing the following:

  • Specifying ColdFusion-specific channel definitions
  • Specifying the ColdFusion Data Service adapter
  • Specifying a destination
  • Enabling ColdFusion-specific debugging output

Specifying ColdFusion-specific channel definitions

LiveCycle Data Services ES transports messages to and from destinations over message channels that are part of the Flex messaging system. When you configure a destination, you reference the messaging channels to use. To connect to a ColdFusion back-end application, ensure that the services-config.xml file contains definitions for the cf-polling-amf channel and the cf-rtmp channel in the channels section. If you are running LiveCycle Data Services ES in ColdFusion, the services-config.xml file is in the wwwroot\WEB-INF\flex directory and contains the channel definitions by default. If you are running LiveCycle Data Services ES remotely, the services-config.xml file is located in the C:\lcds\jrun4\servers\default\samples\WEB-INF\flex folder when you install Flex in the default location.

The channel definitions include the following:

<channel-definition id="cf-polling-amf" class="mx.messaging.channels.AMFChannel">
    <endpoint url="http://{server.name}:{server.port}{context.root}/
    flex2gateway/cfamfpolling" class="flex.messaging.endpoints.AMFEndpoint"/
    >
        <properties>
            <polling-enabled>true</polling-enabled>
                <serialization>
                    <instantiate-types>false</instantiate-types>
                </serialization>
        </properties>
</channel-definition>

<channel-definition id="cf-rtmp" class="mx.messaging.channels.RTMPChannel">
    <endpoint url="rtmp://{server.name}:2048"
    class="flex.messaging.endpoints.RTMPEndpoint"/>
        <properties>
            <idle-timeout-minutes>20</idle-timeout-minutes>
            <serialization>
                <!-- This must be turned off for any CF channel -->
                <instantiate-types>false</instantiate-types>
            </serialization>
        </properties>
</channel-definition>

Specifying the ColdFusion Data Service adapter

Flex provides adapters to connect to various back-end applications. To use the ColdFusion Data Service adapter, you specify it in the data management configuration file by copying the following adapter-definition to the adapters section of the data-management-config.xml file that is in the WEB-INF/flex folder of the server on which you want to run the Flex application. If you are running LiveCycle Data Services ES in ColdFusion, the data-management-config.xml file contains the adapter definitions by default.

The adapter definition includes the following line:

<adapter-definition id="coldfusion-dao" class="coldfusion.flex.CFDataServicesAdapter"/>

Specifying a destination

A destination is the server-side service or object that you call. You configure Data Management destinations in the data-management-config.xml file.

The destination contains the following elements:

Element

Description

destination id

The ID must be unique for each destination.

adapter

The name of the adapter to use. You use the ColdFusion adapter element for any ColdFusion specific destinations.

channels

Use the ColdFusion configured channels that have the instantiate-types flag set to false.

component

The name or path of the assembler CFC.

scope

The scope, which can be application, session, or request. The application value specifies that there is only one instance; request specifies that there is a new CFC for each call. ColdFusion does not support session. (Do not confuse this setting with the ColdFusion variable scope; they are not related.)

use-accessors

Whether the Value Object CFC has getters and setters. Set the value of use-accessors to true if there are getters and setters in the Value Object CFC. However, if you set use-accessors to true and there are no getters and setters in the value object CFC, ColdFusion sets the value of any property of the value object CFC in the this scope. If your CFC does not have any getters and setters, you can increase performance by setting this to false so that ColdFusion does not spend time looking for these methods. The default value is true.

use-structs

Whether to translate ActionScript to CFCs. Set the value of use-structs to true if you don't require any translation of ActionScript to CFCs. The assembler can still return structures to Flex, even if the value is false. The default value is false.

hostname

The hostname or IP address of the ColdFusion host. If you are running LiveCycle Data Services as part of ColdFusion you do not specify a hostname or IP address; however, if you are running LiveCycle Data Services ES remotely, you must specify a hostname or IP address.

identity

The ID of the ColdFusion Data Management server as configured in the ColdFusion Administrator.

This is required only if you are accessing a ColdFusion server remotely using RMI and have more than one instance of ColdFusion on a machine.

remote-username

remote-password

Credentials to pass to the assembler CFC for all clients. It is generally preferable to use the ActionScript setRemoteCredentials() API on the client.

method-access-invoke

The access level of the CFC, which can be public (including remote) or remote.

force-cfc-lowercase

force-query-lowercase

force-struct-lowercase

Whether to make property names, query column names, and structure keys lowercase when converting to ActionScript. Query column names must precisely match the case of the corresponding ActionScript variables. The default value is false.

identity property

The property or list of properties that are the primary key in the database.

query-row-type

Optional. If the assembler fill method returns a query, you must define an ActionScript type for each row in the query that the ArrayCollection returned.

fill-method

Whether to update the results of a fill operation after a create or update operation.

use-fill-contains

Optional. Whether the assembler has a fill-contains method. This method is used to determine whether to refresh the fill. If the specified method returns true, the fill is re-executed after a create or update operation. Set use-fill-contains to true only when auto-refresh is set to true. The default value is false.

auto-refresh

Optional. Whether to refresh the fill after a create or update operation. The default value is true.

ordered

Optional. Whether order is important for this filled collection. Allows performance optimization when order is not important. The default value is true.

The following code shows a sample destination:

<destination id="cfcontact">
    <adapter ref="coldfusion-dao"/>

    <channels>
        <channel ref="cf-rtmp"/>
        <channel ref="cf-polling-amf"/>
    </channels>

    <properties>
        <component>samples.contact.ContactAssembler</component>
        <scope>request</scope>
        <use-accessors>true</use-accessors>
        <use-structs>false</use-structs>
        <hostname>localhost</hostname>
        <identity>default</identity>
        <remote-username></remote-username>
        <remote-password></remote-password>
        <access>
            <method-access-level>remote</method-access-level>
        </access>
        <property-case>
            <force-cfc-lowercase>false</force-cfc-lowercase>
            <force-query-lowercase>false</force-query-lowercase>
            <force-struct-lowercase>false</force-struct-lowercase>
        </property-case>
        <metadata>
            <identity property="contactId"/>
            <query-row-type>samples.contact.Contact</query-row-type>
        </metadata>
        <network>
            <!-- Add network elements here. -->
        </network>

        <server>
            <fill-method>
                <use-fill-contains>false</use-fill-contains>
                <auto-refresh>true</auto-refresh>
                <ordered>true</ordered>
            </fill-method>
        </server>
    </properties>
</destination>

Enabling ColdFusion-specific debugging output

You enable ColdFusion-specific debugging output in the Flex console by adding the following <pattern> tag in the <filters> tag in the logging section in the services-config.xml file:

<pattern>DataService.coldfusion</pattern>

For more information, see "Configuring the Data Service" in Developing Flex Applications, which is included in the Flex documentation.

Note: The ColdFusion Administrator lets you enable or disable LiveCycle Data Management support. If you are running more than one instance of ColdFusion, you must use a unique ID to specify each instance of ColdFusion for which you enable LiveCycle Data Management support. You do so by specifying the identity in the identity element in the data-management-config.xml file.