Brian, I am certainly not against ColdSpring and I understand that using a
mapping is often preferrable to this approach, I just offer it as an
alternative. I realised I asked why it is not good and I can see that for
certain uses of CFCs that you pointed out it is clearly not. However, I do
thnk you are mistaken to both it and Ben's UDF's purpose.
Ben's approach really is the same as mine accept for some minor details.
With his, the directory in which the components are kept is hard coded into
the function, 'www_cfc'. If that part was not in his function it would be
the same as mine accept for its use of cfobject where mine uses cfinvoke.
This difference was the reason I posted it.
It is just an alternative to using a mapping, if you are thinking of using
ColdSpring et. al. you are quite right in that it should never come in to
the equation - but not everyone should or will ever be using ColdSpring.
Lets say you have a few components that you often use in projects that are
deployed to many different hosts. You're entire approach is not OO but you
want to use these components nonetheless; this kind of solution could be of
use as an alternative to setting up a mapping on each deployment. That is
all.
Perhaps I was not clear in the initial post, but here is an example of how
this works to solve the problem of not being able to use relative paths for
components. Let us say you have the following folder struct:
wwwroot\
wwwroot\application.cfm
wwwroot\components\
wwwroot\components\subFolder\
wwwroot\components\subFolder\myCFC.cfc
wwwroot\templates\
wwwroot\templates\myCallingTemplate.cfm
If you want to invoke myCFC.cfc from myCallingTemplate.cfm you might do so
with a mapping called 'myMapping' which maps to wwwroot\components\ and in
myCallingTemplate.cfm you could do:
<cfinvoke component="myMapping.subFolder.myCFC" method="init"
returnvariable="myObj">
Placing the GetCFC UDF in the wwwroot\components\ folder has the same effect
as this mapping in that it gives you a reference point from that location.
So, in application.cfm/cfc:
<cfinclude template="components\getCFC.cfm">
<cfset application.getCFC = getCFC>
Then in myCallingTemplate.cfm:
<cfset myObj = application.getCFC("subFolder.myCFC")>
It is a very simple 'factory' yes, but if simple is what you need then it is
a useable alternative to a mapping. Also, in the above example, I think that
you WOULD be 'forced' into using a mapping should you want to do this and
not use such a factory or ColdSpring, etc. Or is there another way that I am
missing?
Dominic
--
Blog it up: http://fusion.dominicwatson.co.uk
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
ColdFusion is delivering applications solutions at at top companies
around the world in government. Find out how and where now
http://www.adobe.com/cfusion/showcase/index.cfm?event=finder&productID=1522&loc=en_us
Archive:
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:293535
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4