Scott,
There are two answers to your question. You can call methods in other
CFCs in two ways. The first way is through Inheritance, take the
following example:
<cfcomponent displayname="ObjectA">
<cffunction name="aFunction">
<cfreturn "A" />
</cffunction>
</cfcomponent>
<cfcomponent displayname="ObjectB" extends="ObjectA">
<cffunction name="bFunction">
<cfreturn "B" />
</cffunction>
</cfcomponent>
Based on this example you could call ObjectB.aFunction() and it would
return "A".
The other method for this is through composition. A quick example of
how this would work is:
<cfcomponent displayname="ObjectB">
<cfset variables.objectA = createObject('component',
'ObjectA').init() />
<cffunction name="bFunction">
<cfreturn "B" />
</cffunction>
<cffunction name="aFunction">
<cfreturn variables.objectA.aFunction() />
</cffunction>
</cfcomponent>
In this example, Object B contains a copy of Object A and when
ObjectB.aFunction() is called, it simply passes that call on to its copy
of objectA.
HTH,
Rich Kroll
> -----Original Message-----
> From: Scott Weikert [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, March 07, 2007 12:27 PM
> To: CF-Talk
> Subject: Nesting CFCs?
>
> Hey gang -
>
> I'm currently revamping various parts of my main app to CFC-ify it up.
> Modernization and all that rot.
>
> Quick question - can you call one CFC from within another CFC? And if
so
> (I imagine so), what's the method?
>
> In my case, I'd like to just have another <cffunction> block in the
same
> CFC file, so that, say, function1 and function2 both can call
function3
> at some point, within that file.
>
> --Scott
>
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Upgrade to Adobe ColdFusion MX7
Experience Flex 2 & MX7 integration & create powerful cross-platform RIAs
http://www.adobe.com/products/coldfusion/flex2/
Archive:
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:271902
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe:
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4