Adobe 38043740 - ColdFusion Standard - Mac Development Manual page 690

Developing applications
Hide thumbs Also See for 38043740 - ColdFusion Standard - Mac:
Table of Contents

Advertisement

DEVELOPING COLDFUSION 9 APPLICATIONS
Flex and AIR Integration in ColdFusion
<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
method can be any of the following:
get
• The Value Object CFC
• Any
• An array
Creating the sync method
The
method lets you keep track of synchronization conflicts by accepting a change list, which is an array of
sync
change objects. In the
method, you pass in an array of changes, loop over the array and apply the changes, and
sync
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
method returns a number that indicates how many records are in a result set. If you use the Bean/DAO
count
methodology, as described in
separately in the DAO CFC.
The
method contains the following essential elements, without any error handling:
count
<cffunction name="count" output="no" returntype="Numeric" access="remote">
<cfargument name="param" type="string" required="no">
<cfreturn variables.dao.count()>
</cffunction>
This
method calls a different
count
without any error handling:
"Writing the ColdFusion
CFCs" on page 680, you create the lower level
method in the DAO CFC, which contains the following essential elements,
count
Last updated 1/20/2012
685
method
count

Advertisement

Table of Contents
loading

This manual is also suitable for:

Coldfusion 9

Table of Contents