Based on the error message, it can't find the createAddress function.  I'm
assuming it is in the same cfc as your create() method, correct?

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf
Of Ken Dunnington
Sent: Tuesday, March 08, 2005 4:15 PM
To: [email protected]
Subject: Re: [CFCDev] Passing and returning var scoped objects?

Alright, let me try and clean this up a bit :) My user object creates
new instances of the address class on initialization, so calling the
getBilling() method will return the address object stored in the user
object's instance variables.

This is the code that is called by the controller (fusebox):
        <cffunction name="store" output="false" returnType="user"
access="public" hint="Create or Update a user">
                <cfargument name="userObj" type="user" required="true"
hint="User to
store." />
                <cfset var user = new() />
                <cfif arguments.userObj.getID() EQ 0>
                        <cfset user = create(arguments.userObj) />
                <cfelse>
                        <cfset user = update(arguments.userObj) />
                </cfif>
                <cfreturn user />
        </cffunction>

Here is the create() function:
        <cffunction name="create" output="false" access="private"
returnType="user" hint="Insert a new user into the database">
                <cfargument name="bean" type="user" required="yes"
hint="User object" />
                <cfset var billing = arguments.bean.getBilling() />
                <cfset var shipping = arguments.bean.getShipping() />
                <!--- CFQUERY transaction here ... --->
                <cfset arguments.bean.setID(newID.id) />
                
                <!--- Create Billing Address - Here's where the failure
occurs --->
                <cfset billing = createAddress(billing) />
                <cfset arguments.bean.setBilling(billing) />
                
                <!--- Create Shipping Address --->
                <cfset shipping = createAddress(shipping) />
                <cfset arguments.bean.setShipping(shipping) />
                
                <!--- Link the addresses to the user in the lookup table
--->
                <cfset
createAddressRef(arguments.bean.getID(),arguments.bean.getBilling().getID(),
"billing")
/>
                <cfset
createAddressRef(arguments.bean.getID(),arguments.bean.getShipping().getID()
,"shipping")
/>
                <cfreturn arguments.bean />
        </cffunction>

And finally, here's the createAddress() function:
        <cffunction name="createAddress" output="false" returnType="address"
access="private" hint="Create a new address entry">
                <cfargument name="address" type="address" required="true" />
                <!--- More CFQUERY transactions here --->
                <cfset arguments.address.setID(newAddressID.id) />
                <cfreturn arguments.address />
        </cffunction>

On Tue, 8 Mar 2005 15:13:19 -0500, Roland Collins <[EMAIL PROTECTED]>
wrote:
> Some code would help greatly!
> 
> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf
> Of Ken Dunnington
> Sent: Tuesday, March 08, 2005 3:03 PM
> To: [email protected]
> Subject: [CFCDev] Passing and returning var scoped objects?
> 
> I have an odd problem, I'm writing a user management system and in my
> create() method, I make a call to a function named createAddress()
> which accepts an address object and returns that object, updated with
> the new primary key. When I make the call, I get the error 'Variable
> createAddress is undefined.' The address object is var scoped, and
> I've tried it without using var with the same result. The strange
> thing is, all my other DAO's use very similar code without problems.
> What could cause a function call to return an undefined variable
> error? Does it have something to do with returning an argument? (I
> return arguments.address - should I copy this to a locally-scoped
> variable first, and pass that back after processing?) Any thoughts
> would be greatly appreciated!
> 
> Thanks
> - Ken
> 
> ----------------------------------------------------------
> You are subscribed to cfcdev. To unsubscribe, send an email to
> [email protected] with the words 'unsubscribe cfcdev' as the subject of
the
> email.
> 
> CFCDev is run by CFCZone (www.cfczone.org) and supported by CFXHosting
> (www.cfxhosting.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' as the subject of the
email.
> 
> CFCDev is run by CFCZone (www.cfczone.org) and supported by CFXHosting
(www.cfxhosting.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' as the subject of the
email.

CFCDev is run by CFCZone (www.cfczone.org) and supported by CFXHosting
(www.cfxhosting.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' as the subject of the 
email.

CFCDev is run by CFCZone (www.cfczone.org) and supported by CFXHosting 
(www.cfxhosting.com).

An archive of the CFCDev list is available at
www.mail-archive.com/[email protected]

Reply via email to