On Thu, Feb 25, 2010 at 9:42 PM, Michael Dinowitz <[email protected]> wrote: > > I'm just looking for verification on what I know about extending cfcs > in the cfcomponent tag. > > Lets say for example I have a component called baseapp.cfc sitting in > the web root. I also have an application.cfc in a directory named > /blog. If I want the application.cfc to extend the baseapp.cfc, I have > to use the following syntax: > extends="/.baseapp"
I haven't actually seen a forward slash used in any component paths, I don't believe it is allowed. It should be a dot delimited path from the webroot, so if your baseapp.cfc is in the directory blog under the webroot, it should be referred to as blog.baseapp > I didn't see anything in CF9 to change the need for this syntax. Is it > possible I missed something? Is there a better way other than creating > a mapping in the CF Admin or moving the extended file out of the root > dir? > > Along the same lines of thought, is there a way to extend a component > without knowing it's exact location? Lets say that the blog directory > is now a subdirectory of /myapps. I want an application.cfc that is in > /myapps/blog/admin to extend the application.cfc sitting one level up > in /myapps/blog. I don't know if the blog directory is in the root of > the site, in myapps, or in some other location. All I know is that the > application.cfc I want to extend is one directory up. Is there a way > to do relative inheritance? > > I expect the answer is no. > > Just double/triple/quadruple checking the basics of inheritance in ColdFusion. As far as I'm aware, CF only does inheritance the way you have covered, either through mappings or references relative to webroot. However, this second part is where Dependency Injection frameworks come in. With a DI framework (like Coldspring or Lightwire) you can set up aliases and pathing and such and just tell your objects "go fetch this thing and make sure that it is all properly set up". I use the DI container baked into Coldbox so I'm not 100% up to speed on the syntax for Coldspring and Lightwire, but I know they will do it. I should mention, however, that as far as I'm aware, DI frameworks don't really do inheritance, they do composition. There is a whole school of discussion much greater than I about the merits of inheritance vs composition, but most people seem to favor composition over inheritance when possible. So, depending on your particular situation, you might find that a framework like Coldspring will solve all your problems in a very elegant fashion without having to resort to inheritance. Cheers, Jud ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Want to reach the ColdFusion community with something they want? Let them know on the House of Fusion mailing lists Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:331152 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

