Thanks, that makes it a little clearer. Now for the newbie dumb
question, how does the code know where to find the components? i.e.

<!--- Instantiate a component that adds two numbers --->
<cfset myAdder = createObject("component", "addsTwoNumbers") />

Do you have to create a mapping to a directory called component that
contains all of the CFC's?

Andy McShane 
Head of Development
Scout7 Ltd, 
324a Lichfield Road, 
Mere Green, 
Sutton Coldfield 
West Midlands 
United Kingdom 
B74 2UW 

Telephone: +44 (0)121 323 2640 
Mobile : 07866 430783 
Fax: +44 (0)121 323 2010 
Email: mailto:[EMAIL PROTECTED] 
Website: www.scout7.com


-----Original Message-----
From: Joe Rinehart [mailto:[EMAIL PROTECTED] 
Sent: 29 November 2004 19:16
To: CF-Talk
Subject: Re: Best way to access CFC's?

If you're component is stateful, you'll want to invoke methods on the
same instance of the component instead of continually creating new
instances.

<!--- Instantiate a component that adds two numbers --->
<cfset myAdder = createObject("component", "addsTwoNumbers") />

<!--- Set first number --->
<cfinvoke 
   component="#myAdder#" 
   method="setNumberOne" 
   <cfinvokeargument 
      name="number" 
      value="2">
</cfinvoke>

<!--- Set second number --->
<cfinvoke 
   component="#myAdder#" 
   method="setNumberTwo" 
   <cfinvokeargument 
      name="number" 
      value="3">
</cfinvoke>

<!--- Get sum --->
<cfinvoke 
   component="#myAdder#" 
   method="getSum"
   returnVariable="sum" 
</cfinvoke>

<!--- Displays five --->
<cfoutput>#sum#</cfoutput>

There's a few different ways to write this....I'd probably use:

<cfset myAdder = createObject("component", "addsTwoNumbers") />
<cfset myAdder.SetNumberOne(2) />
<cfset myAdder.SetNumberTwo(3) />
<cfoutput>#myAdder.getSum()#</cfoutput>

-joe


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Special thanks to the CF Community Suite Silver Sponsor - CFDynamics
http://www.cfdynamics.com

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:185641
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to