Solved

Extending with a dynamic cfc path

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

Connect further...control easier

With the ATEN CE624, you can now enjoy a high-quality visual experience powered by HDBaseT technology and the convenience of a single Cat6 cable to transmit uncompressed video with zero latency and multi-streaming for dual-view applications where remote access is required.

Question has a verified solution.

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

One of the typical problems I have experienced is when you have to move a web server from one hosting site to another. You normally prepare all on the new host, transfer the site, change DNS and cross your fingers hoping all will be ok on new server…
Lease-to-own eliminates the expenditure of hardware replacement and allows you to pay off the server over time. Usually, this is much cheaper than leasing servers. Think of lease-to-own as credit without interest.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

856 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