Your understanding is correct, Matt, but I don't see how your example is relevant.
In my application.cfc, I've got a line that sets an application variable: <cfset application.siteShortDomain = "myShortDomain.com"> I need that application.siteShortdomain variable available when contact.cfc runs. So, how would I go about this? (I just noticed what Brian and Russ added to the conversation, and Russ is correct, as you can see from above, that I want to extend the global application variables that I've set in application.cfc tp all the other cfc's that are in a common library of cfc's above the website root. ??? Thanks! Rick On Tue, Jun 25, 2013 at 11:50 AM, Matt Quackenbush <quackfu...@gmail.com>wrote: > > Hang on a minute. If I understand this correctly .... > > So, how do I make the variables from application.cfc available to > > contact.cfc under > > such a scenario? Does the "extends" functionality of cfc's solve this? > > > ... you're thinking about adding `extends="Application"` to your > contact.cfc? If that's a correct understanding on my part, then the answer > is: "HELL NO! DO NOT USE EXTENDS!" > > Your CFCs should be self-contained and any "outside" variables they need > should be passed in as either arguments or properties. Here's a contrived > example. > > // foo.cfc > component > { > property name="datasourcename" > > function init( required string datasourcename ) > { > variables.datasourcename = arguments.datasourcename > return this > } > > function doQuery() > { > // your query goes here > return mycoolquery > } > } > > // test.cfm > foo = createObject( 'component', 'foo' ).init( application.datasourcename ) > writeDump( foo.doQuery ) > > > HTH > > On Tue, Jun 25, 2013 at 11:41 AM, Rick Faircloth > <r...@whitestonemedia.com>wrote: > > > > > Alright, that's the confirmation I needed to proceed. So, "use 'extends" > it > > is! > > > > Thanks, > > > > Rick > > > > > > On Tue, Jun 25, 2013 at 11:21 AM, Russ Michaels <r...@michaels.me.uk> > > wrote: > > > > > > > > if you use EXTENDS, then everything in the parent CFC is available tot > he > > > child. > > > If you want libraries to use on multiple sites, then you would need to > > put > > > the components in a central location and then adding a mapping to them. > > > > > > > > > > > > On Tue, Jun 25, 2013 at 4:01 PM, Rick Faircloth < > > r...@whitestonemedia.com > > > >wrote: > > > > > > > > > > > Hi, all... > > > > > > > > I've been writing code for every project I've worked on for the last > > 10+ > > > > years. > > > > I did that purposefully to make myself work in a manner which would, > > > > hopefully, > > > > not cause me to rely on known practices because they were familiar > and > > > > understood, but always strive to discover better ways of coding. > > > > > > > > Now, however, I'm trying to combine reusing code I've already written > > > with > > > > enhancing the reused code, instead of writing it from scratch each > > time. > > > > > > > > On my latest project I decided to take the dive and structure my code > > of > > > > HTML, > > > > CF, jQuery, and CSS in away that allows me to create resource > libraries > > > > that I can build upon and reference from within new projects. > > > > > > > > I know *not* doing it this way sounds nuts to some of you. But, > again, > > > see > > > > my > > > > first paragraph. There was a method to the madness of this approach. > > > > > > > > But, now I find myself (after days of trying to understand what I've > > > found > > > > on the > > > > Internet and in the CF docs to little avail) trying to get a working > > > > method for this > > > > approach. > > > > > > > > I started first by putting my initial components for the project > > *above* > > > > the website's > > > > root folder. I knew this was going to be problematic. I, of course, > > > > immediately > > > > got the error, "component cannot be found." > > > > > > > > Then, I read about "cfincluding" an application.cfc into an > > > application.cfm > > > > in the > > > > website root folder. For "kicks and giggles", not a real solution, > > > because > > > > this approach > > > > is fundamentally flawed, I put an application.cfm in the site root > > folder > > > > and > > > > used the relative path capability of <cfinclude> to pull in the > > > > application.cfc above > > > > the site web root and it's settings into the site's directory > > structure. > > > > Knowing that's > > > > not a solution, I continued to dig on the Internet. Nothing has > > clicked. > > > I > > > > think there > > > > are too many gaps in my understanding to make sense of everything I'm > > > > reading. > > > > > > > > So, I thought I'd just ask the brains that inhabit the world of > CF-Talk > > > and > > > > ask > > > > for a simple explanation of how to go about accessing cfc's above a > > > website > > > > root, > > > > that allows those cfc's access to the variables set up in > > application.cfc > > > > when it > > > > resides inside the site root directory structure. > > > > > > > > I'm trying to get this to work in the manner that I access virtually > > > every > > > > cfc currently, > > > > which is through AJAX functionality in jQuery. I can access a mapped > > path > > > > created > > > > in application.cfc using AJAX in this manner: > > > > > > > > url: location.protocol + '//' + location.host + > > > > '/common/coldfusion/form-processing/contact.cfc?method=json' > > > > > > > > However, the "contact.cfc" has to reference variables setup in the > > > > application.cfc, > > > > which exists inside the website root. Unless I place the > > application.cfc > > > in > > > > the same > > > > folder as "contact.cfc", it doesn't work. > > > > > > > > So, how do I make the variables from application.cfc available to > > > > contact.cfc under > > > > such a scenario? Does the "extends" functionality of cfc's solve > this? > > Is > > > > that what > > > > I need to understand and implement or do I need to look into > something > > > > else? > > > > > > > > Clues? Breadcrumbs? > > > > > > > > Thanks for any feedback! > > > > > > > > Rick > > > > > > > > -- > > > > > > > > > > > > > > -------------------------------------------------------------------------------------------------------------------------------------------------- > > > > "Ninety percent of the politicians give the other ten percent a bad > > > > reputation." Henry Kissinger > > > > > > > > > > > > > > > > > > > > > > > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:356054 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm