
684
DEVELOPING
COLDFUSION 9 APPLICATIONS
Flex and AIR Integration in ColdFusion
Las
t
upda
te
d 8/5/2010
The
fillContains
method has the following arguments:
•
fillArgs
is a list of arguments to pass to the
fill
method.
•
item
is the record to check to determine if it is in the result set.
•
isCreate
indicates whether the record is new.
A sample
fillContains
method, which determines whether the
fill
arguments (part of the first or last name) are
in the Contact item passed to the function, is as follows:
<cffunction name="fillContains" output="no" returnType="boolean"access="remote">
<cfargument name="fillArgs" type="array" required="yes">
<cfargument name="item" type="samples.contact.Contact" required="yes">
<cfargument name="isCreate" type="boolean" required="yes">
<cfif ArrayLen(fillArgs) EQ 0>
<!--- This is the everything fill. --->
<cfreturn true>
<cfelseif ArrayLen(fillArgs) EQ 1>
<!--- This is a search fill. --->
<cfset search = fillArgs[1]>
<cfset first = item.getFirstName()>
<cfset last = item.getLastName()>
<!--- If the first or last name contains the search string, --->
<cfif (FindNoCase(search, first) NEQ 0) OR (FindNoCase(search, last)
NEQ 0)>
<!--- this record is in the fill. --->
<cfreturn true>
<cfelse>
<!--- this record is NOT in the fill. --->
<cfreturn false>
</cfif>
</cfif>
<!--- By default, do the fill.--->
<cfreturn true>
</cffunction>
If you are running LiveCycle Data Services ES locally, you can determine whether a
fill
operation is a refresh or a
client triggered fill. You do so by calling the DataServiceTransaction.getCurrentDataServiceTransaction().isRefill()
method in your ColdFusion application as follows:
<cfscript>
dst = CreateObject("java", "flex.data.DataServiceTransaction");
t = dst.getCurrentDataServiceTransaction();
isRefill = t.isRefill();
</cfscript>
This does not work over RMI when ColdFusion and Flex are not in the same web application.
Creating the get method
The
get
method retrieves a specific record. The get method calls the lower level
read
method. If you use the
Bean/DAO methodology, as described in “
Writing the ColdFusion CFCs
” on page 680, you create the lower level
read
method separately in the DAO CFC.
The following example shows the essential elements of a
get
method: