?
Solved

Extending with a dynamic cfc path

Posted on 2008-10-21
3
Medium Priority
?
525 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 2000 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

Get MongoDB database support online, now!

At Percona’s web store you can order your MongoDB database support needs in minutes. No hassles, no fuss, just pick and click. Pay online with a credit card. Handle your MongoDB database support now!

Question has a verified solution.

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

Hi, I will be creating today a basic tutorial on how we can create a Mail Custom Function and use it where ever we want. The main advantage about creating a custom function is that we can accommodate a range of arguments to pass to the Function and …
If you don't have the right permissions set for your WordPress location in IIS, you won't be able to perform automatic updates. Here's how to fix the problem.
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

777 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