
683
DEVELOPING
COLDFUSION 9 APPLICATIONS
Flex and AIR Integration in ColdFusion
Las
t
upda
te
d 8/5/2010
•
Ensure that the query column names match the case of the properties in the ActionScript object. Use the
property-case
settings in the destination to do so. Set the
force-query-lowercase
element to
false
so that
ColdFusion converts all column names to lowercase.
•
If you are using an array of structures:
•
Create the array to contain the Value Objects, as follows:
<cfset var ret = ArrayNew(1)>
•
Loop through the query to create the structure that contains the results of the query, for example:
<cfloop query="qRead">
<cfscript>
stContact = structNew();
stContact["__type__"] = "samples.contact.Contact";
stContact["contactId"] = qRead.contactId;
stContact["firstName"] = qRead.firstName;
stContact["lastName"] = qRead.lastName;
stContact["address"] = qRead.address;
stContact["city"] = qRead.city;
stContact["state"] = qRead.state;
stContact["zip"] = qRead.zip;
stContact["phone"] = qRead.phone;
ArrayAppend(ret, duplicate(stContact));
</cfscript>
</cfloop>
•
Use the
__type__
structure element to specify that the Value Object CFC is the type, for example:
stContact["__type_"] = "samples.contact.Contact";
•
Use the associative array syntax, for example,
contact["firstName"]
to ensure that you match the case of the
ActionScript property. If you use the other syntax, for example,
contact.firstName="Joan"
, ColdFusion
makes the key name uppercase.
Managing fills
To determine whether to refresh a fill result after an item is created or updated, you include a
fillContains
method
in the assembler and set both
use-fill-contains
and
auto-refresh
to
true
in the fill-method section of the data-
management-config.xml file. The following example shows a fill-method section:
<fill-method>
<use-fill-contains>true</use-fill-contains>
<auto-refresh>true</auto-refresh>
<ordered>false</ordered>
</fill-method>
In this example,
ordered
is set to
false
because the fill result is not sorted by any criteria. However, if the fill result is
sorted, you set
ordered
to
true
. When an item changes in a fill result that is ordered, refresh the entire fill result.
The
fillContains
method tells the Flex application whether it is necessary to run the fill again after an item in the
fill result has changed. The
fillCcontains
method returns a value that indicates how the fill be treated for that
change. When the
fillContains
method returns
true
, the fill is executed after a create or update operation.
The following example shows the
fillContains
method signature:
<cffunction name="fillContains" output="no" returnType="boolean" access="remote">
<cfargument name="fillArgs" type="array" required="yes">
<cfargument name="item" type="[CFC type object]" required="yes">
<cfargument name="isCreate" type="boolean" required="yes">