I'm assuming you have some general functions that you would like to use
within several CFCs? 

How about writing functions.cfm as a separate utility component that is
injected into subset.cfc when it's instantiated and then you can use your
function within subset.cfc when you overwrite original implementation? 


So it would be something like 

subset.cfc: 

<cfcomponent extends="cfcs.base">
        <cffunction name="init">
                <cfargument name="utility">
                <cfset this.utility = arguments.utility>
        </cffunction>

        <cffunction name="doStuff">
                <cfdosomeothersuff>
                <cfreturn this.utility.doStuff()>
        </cffunction>
</cfcomponent>


I'm pretty strongly against using cfinclude inside CFC; that typically just
leads to bloated components that are difficult to understand because code is
scattered around several files. 

Hope this helps


Tero Pikala



-----Original Message-----
From: Jake Pilgrim [mailto:[EMAIL PROTECTED] 
Sent: 24 April 2007 19:07
To: CF-Talk
Subject: CFCs that extend CFCs - want to cfinclude a function

I have a CFC that extends another CFC, and I want to overwrite a function in
the base CFC using a cfinclude. Take the following example:

subset.cfc:
<cfcomponent extends="cfcs.base">
  <cfinclude template="functions.cfm" />
</cfcomponent>

base.cfc:
<cfcomponent>
  <cffunction name="doStuff">
     <cfset returnVal = 1 />
     <cfreturn returnVal />
  </cffunction>
</cfcomponent>

functions.cfm:
<cffunction name="doStuff">
  <cfset returnVal = 2 />
  <cfreturn returnVal />
</cffunction>


Now if i paste the contents of function.cfm to where the cfinclude is the
functions.cfm version of doStuff() overwrites the base version of doStuff()
(good), but when i extract it into a separate file and use the cfinclude, it
does not overwrite doStuff() (bad). 

Anyone know of a good workaround for this?

Thanks!
Jake Pilgrim



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
ColdFusion MX7 by AdobeĀ®
Dyncamically transform webcontent into Adobe PDF with new ColdFusion MX7. 
Free Trial. http://www.adobe.com/products/coldfusion?sdid=RVJV

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:277621
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4

Reply via email to