Solved

Extending with a dynamic cfc path

Posted on 2008-10-21
3
517 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

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

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

Hi, Even though I have created this Tutorial on My personal Blog, Some people might not able to find my website, So here i am posting it again Today, from the topic it is very clear that i will be showing you here the very basic usage of how we …
Hi. There are several upload tutorials using jquery and coldfusion. I found a very interesting one here Upload Your Files using Jquery & ColdFusion and Preview them (http://www.randhawaworld.com/) . I did keep the main js functions but made sever…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

697 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