Hello.

I'm working with a component that is stored in application scope. When a
duplicate() of the application scope is performed like in the code below, I
get an error that says the variable 'instance' is not defined when I try to
run request.app.objSQLServerDAOFactory.dump(). Calling
application.objSQLServerDAOFactory.dump() works fine.

lock
application.objSQLServerDAOFactory =
application.objDAOFactory.init(application.objDAOFactory.SQLServer);
request.app = duplicate(application);
/lock

However, if duplicate is not used as in request.app = application; then
running request.app.objSQLServerDAOFactory.dump() runs as expected.

Can someone explain to me why this is? I'm know duplicate() does a deep copy
and assigning the value directly just gives you a reference to the original
variable.

SQLServerDAOFactory Code
--------------------------------------------
<cfcomponent displayname="SQLServerDAOFactory" hint="Creates SQL Server DAO
components">
        
        <cfset init()>
        
        <cffunction name="init" access="package" output="false"
returntype="void">
                <cfset instance = structnew()>
                <cfset instance.datasource = "">
        </cffunction>   
        
        <cffunction name="getPageDAO" access="public" output="false"
returntype="PageDAO">
                <cfset obj = createobject("component", "PageDAO")>
                <cfset obj.setDatasource(instance.datasource)>
                <cfreturn obj>
        </cffunction>
        
        <cffunction name="setDatasource" access="package" output="false"
returntype="void">
                <cfargument name="datasource" type="string" required="yes">
                <cfset instance.datasource = arguments.datasource>
        </cffunction>
        
        <cffunction name="dump" access="public" output="true"
returntype="void">
                <cfdump var="#instance#">
        </cffunction>
        
</cfcomponent>

Thanks,
Phillip

--

Phillip Cave
Director, ColdFusion Development
Macromedia Certified ColdFusion Developer
Carol/Trevelyan Strategy Group 
202.448.5212

----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email
to [EMAIL PROTECTED] with the word '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]

Reply via email to