44
Using the Flex Data Service Assembler
The arguments are as follows:
■
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>
Authentication
To authenticate users when using the Flex Data Service Assembler, you use the Flex
setRemoteCredentials()
method on the DataService object. The credentials, which are in
the FlexSession object, are passed to the ColdFusion application, where you can use the
cflogin
tag to perform authentication. Alternatively, you can set credentials in the Flex
destination, although this is not the recommended way to do so.