
685
DEVELOPING
COLDFUSION 9 APPLICATIONS
Flex and AIR Integration in ColdFusion
Las
t
upda
te
d 8/5/2010
<cffunction name="get" output="no" returnType="samples.contact.Contact" access="remote">
<cfargument name="uid" type="struct" required="yes">
<cfset key = uid.contactId>
<cfset ret=variables.dao.read(id=key)>
<cfreturn ret[1]>
</cffunction>
The returntype of a
get
method can be any of the following:
•
The Value Object CFC
•
Any
•
An array
Creating the sync method
The
sync
method lets you keep track of synchronization conflicts by accepting a change list, which is an array of
change objects. In the
sync
method, you pass in an array of changes, loop over the array and apply the changes, and
then return the change objects, as follows:
<cffunction name="sync" output="no" returnType="array" access="remote">
<cfargument name="changes" type="array" required="yes">
<!-- Create the array for the returned changes. -->
<cfset var newchanges=ArrayNew(1)>
<!-- Loop over the changes and apply them. --->
<cfloop from="1" to="#ArrayLen(changes)#" index="i" >
<cfset co = changes[i]>
<cfif co.isCreate()>
<cfset x = doCreate(co)>
<cfelseif co.isUpdate()>
<cfset x = doUpdate(co)>
<cfelseif co.isDelete()>
<cfset x = doDelete(co)>
</cfif>
<cfset ArrayAppend(newchanges, x)>
</cfloop>
<!-- Return the change objects, which indicate success or failure. --->
<cfreturn newchanges>
</cffunction>
Creating the count method
The
count
method returns a number that indicates how many records are in a result set. If you use the Bean/DAO
methodology, as described in “
Writing the ColdFusion CFCs
” on page 680, you create the lower level
count
method
separately in the DAO CFC.
The
count
method contains the following essential elements, without any error handling:
<cffunction name="count" output="no" returntype="Numeric" access="remote">
<cfargument name="param" type="string" required="no">
<cfreturn variables.dao.count()>
</cffunction>
This
count
method calls a different
count
method in the DAO CFC, which contains the following essential elements,
without any error handling:
Содержание COLDFUSION 9
Страница 1: ...Developing Applications ADOBE COLDFUSION 9...