Solved

Extending with a dynamic cfc path

Posted on 2008-10-21
3
511 Views
Last Modified: 2013-12-24
Using some cfcs in that are subdivided in the CFC directory.  For instance have myCFC and myChildCFC folders.  The myCFC folder contains myCFC.cfc and myChildCFC contains myChildCFC.cfc.  I'm trying to have myChildCFC extend myCFC.  But my root folder (call it myWebsite) needs to be dynamic, so could have myWebsite2 for instance.  I'm unable to put anything but a constant expression in the extends as it throws an error.  How do I get the extend attribute in myCFC.cfc to see the myChildCFC.cfc.  I tried extends="cfcs.myCFC.myCFC".  This doesn't seem to work.

Thanks
0
Comment
Question by:HyperBPP
  • 2
3 Comments
 
LVL 27

Expert Comment

by:azadisaryev
ID: 22773033
this works fine on my CF8 server:

folder structure:
/ - site root
/dev - sub-folder under site root
  files: test_com.cfm - testing page
/dev/com - main components dir
  files: myCFC.cfc - component that will be extended by the child component
/dev/com/childcom - child component dir
  files: myChildCFC.cfc - the cild component that will extend the min component

test_com.cfm page in /dev:

<!--- instantiate myCFC component --->
<cfset oMyCFC = createobject('component', 'com.myCFC')>
<!--- invoke f1 function from myCFC component --->
<cfset res = oMyCFC.f1()>
<!--- output result of f1 function --->
<cfoutput>#res#</cfoutput>

myCFC.cfc component in /dev/com:

<cfcomponent displayname="myCFC" extends="dev.com.childcom.myChildCFC">
      <cffunction name="f1" access="public" returntype="string">
            <cfset var myResult=f2()>
            <cfreturn myResult>
      </cffunction>
</cfcomponent>

myChildCFC component in /dev/com/childcom:

<cfcomponent displayname="myChildCFC">
      <cffunction name="f2" access="public" returntype="string">
            <cfset var myResult="I am f2 function from myChildCFC component!">
            <cfreturn myResult>
      </cffunction>
</cfcomponent>


test_com.cfm page outputs "I am f2 function from myChildCFC component!"

hth
0
 
LVL 6

Author Comment

by:HyperBPP
ID: 22786026
This is reverse what I need.  You have myCFC extending myChildCFC.  However I need myChildCFC to extend myCFC.  Additionally I don't see that you would have the same issues as I do.  SInce myCHildcfc is in a subdirectory of the directory containing myCFC, myCFC should be to find it.  In my case, myChildCFC needs to access a file in a directory that is not a subdirectory of the directory it is in.  
0
 
LVL 27

Accepted Solution

by:
azadisaryev earned 500 total points
ID: 22792904
sorry, i have misinterpreted your configuration...
in any case, the same principle should work: provide a path to the cfc you want to extent from web root.
if the cfc you want to extend is not under same web root as the cfc extending it, you will need to create a cf mapping to the folder containing that cfc: in CF Administrator got to Mappings (under Server Settings) and add a mapping to the folder containing myCFC.cfc. then in MyChildCFC the extends attribute should just use that mapping's name.

example:
C:\coms\myCFC - a folder containing myCFC.cfc
/dev - website's root
/dev/com - folder containing MyChildCFC.cfc

Created CF mapping: Logical path: myCFC; Directorty path: C:\coms\MyCFC

Extends attribute in myChildCFC: extends="myCFC"

hth
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction This article explores the design of a cache system that can improve the performance of a web site or web application.  The assumption is that the web site has many more “read” operations than “write” operations (this is commonly the ca…
Meet the world's only “Transparent Cloud™” from Superb Internet Corporation. Now, you can experience firsthand a cloud platform that consistently outperforms Amazon Web Services (AWS), IBM’s Softlayer, and Microsoft’s Azure when it comes to CPU and …
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question