Sean: restarting the CF server did not help
David: Your suggestion helped in solving the problem. However, it lead to an
extra CFC to maintain. To create a list of employees there are now 3 CFC's
involved: the flashgateway.cfc, the employeemanager.cfc and the
employeegateway.cfc. This feels to me like asking the nephew of my parents
neighbours how my parents are doing. I have read that Flash Remoting does
not provide a mechanism for directly accessing components stored in
application and session scopes. Does this mean that there is no way to
combine the flashgateway.cfc and the employeemanager.cfc or reduce the
number of cfc's in another way while maintaining the pattern? Sean, can we
expect tighter integration between Flash Remoting and Blackstone (directly
accessing components stored in application and session scope?
The latest versions
Application.cfm:
<cfscript>
APPLICATION.dataSource = "AtlantisDatabase";
APPLICATION.ApplicationName = "Atlantis";
</cfscript>
<cfif not structKeyExists(application,"employeeManager")>
<cflock name="#APPLICATION.ApplicationName#_employeeManager"
type="exclusive" timeout="10">
<cfif not structKeyExists(application,"employeeManager")>
<cfset application.employeeManager =
createObject("component","atlantis.model.employeemanager").init() />
</cfif>
</cflock>
</cfif>
flashgateway.cfc:
<cfcomponent>
<cffunction name="getAllEmployees" access="remote" returntype="query"
output="false" hint="I return employees to flash">
<cfreturn application.employeeManager.getAllEmployees() />
</cffunction>
</cfcomponent>
employeemanager.cfc:
<cfcomponent displayname="Employee Manager" hint="I am the facade for the
Atlantis application">
<cffunction name="init" access="public"
returntype="atlantis.model.employeemanager" output="false"
displayname="Constructor" hint="I initialize the Employee Manager.">
<cfset var dsn = "#APPLICATION.DataSource#" />
<cfset VARIABLES.employeeGateway =
createObject("component","atlantis.model.employeegateway").init(dsn) />
<cfset VARIABLES.employeeDAO =
createObject("component","atlantis.model.employeedao").init(dsn) />
<cfreturn this />
</cffunction>
<cffunction name="getAllEmployees" access="public" returntype="query"
output="false" displayname="Get All Employees" hint="I return a query
containing all employees.">
<cfreturn VARIABLES.employeeGateway.getEmployees() />
</cffunction>
</cfcomponent>
employeegateway.cfc
<cfcomponent displayname="Employee Gateway" hint="I am a data gateway to
employees for the Atlantis application">
<cffunction name="init" access="public"
returntype="atlantis.model.employeegateway" output="false"
displayname="Employee Gateway Constructor" hint="I initialize the employee
gateway.">
<cfargument name="dsn" type="string" required="yes" displayname="Data
Source Name" hint="I am the data source to use for persistence." />
<cfset VARIABLES.dsn = ARGUMENTS.dsn />
<cfreturn this />
</cffunction>
<cffunction name="getEmployees" access="remote" returntype="query"
output="false" displayname="Get Employees" hint="I return a query containing
employees in alphabetical order.">
<cfset var returnQuery="" />
<cfquery name="returnQuery" datasource="#VARIABLES.dsn#">
<!--- query statements--->
</cfquery>
<cfreturn returnQuery />
</cffunction>
</cfcomponent>
Thanks a lot for your help!
Vinny
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf
Of David Ross
Sent: dinsdag 3 februari 2004 20:35
To: [EMAIL PROTECTED]
Subject: RE: [CFCDev] implementing Sean Corfields data access pattern
withoutmach-ii
Vinny:
I don't think you can call remote methods on persistant objects. As I said
before, when you call a remote method, you get a new instance of the CFC
each time.
Try this:
in application.cfm (note the <cfset ... object is scoped to
application):
<cfif not structKeyExists(application,"employeeManager")>
<cflock name="#APPLICATION.ApplicationName#_employeeManager"
type="exclusive" timeout="10">
<cfif not structKeyExists(application,"employeeManager")>
<cfset application.employeeManager =
createObject("component","atlantis.model.employeemanager").init() />
</cfif>
</cflock>
</cfif>
In employeeManager (note access="public" in getAllEmployees) :
<cffunction name="getAllEmployees" access="public"
returntype="query"
output="false" displayname="Get All Employees" hint="I return a query
containing all employees.">
<cfreturn VARIABLES.employeeGateway.getEmployees() />
</cffunction>
>From here, you will need a CFC to serve as your data gateway to flash.
(You were trying to use employeeManager.cfc, but that won't work if you want
it to persist in the application scope):
<cfcomponent>
<cffunction name="getAllEmployees" access="remote"
returntype="query"
output="false" hint="I return employees to flash">
<cfreturn application.employeeManager.getAllEmployees() />
</cffunction>
</cfcomponent>
let me know if this helps.
-dave
----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email to
[EMAIL PROTECTED] with the words 'unsubscribe cfcdev'
in the message of the email.
CFCDev is run by CFCZone (www.cfczone.org) and supported by Mindtool,
Corporation (www.mindtool.com).
An archive of the CFCDev list is available at
www.mail-archive.com/[EMAIL PROTECTED]
----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email
to [EMAIL PROTECTED] with the words 'unsubscribe cfcdev'
in the message of the email.
CFCDev is run by CFCZone (www.cfczone.org) and supported
by Mindtool, Corporation (www.mindtool.com).
An archive of the CFCDev list is available at www.mail-archive.com/[EMAIL PROTECTED]