Solved

Extending with a dynamic cfc path

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
recordcount is coming as undefined in query 4 55
Coldfusion combining queries 15 65
Coldfusion RegEx 8 49
Fixing Old Legacy Code 1 5
Sometimes databases have MILLIONS of records and we need a way to quickly query that table to return the results me need. Sure you could use CFQUERY but it takes too long when there are millions of records. That is why SOLR was invented. Please …
When it comes to showing a 404 error page to your visitors, you do not want that generic page to show, and you especially do not want your hosting provider’s ad error page to show either. In this article, I will show you how to enable the custom 40…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

758 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now