>
> What you've described is not the same as what the original poster is
> asking
> about. He want to use relative paths.


What I described is exactly as the link that you posted in your original
response and is a solution to the OP (though clearly not the best). He wants
to be able to use a cfc that lies in a directory a back from the calling
template. This allows you to do that, as does a mapping.


> You have created a simple factory, but you still have to either know the
> full path to the target CFC (which is not what he was wanting), or you have
> to have all your CFCs in a single folder (which is not very easy to deal
> with if you have many components).


You need to know the same amount of information about the location of the
cfc as you would using a standard mapping. Placing and using the udf in a
directory called c:\wwwroot\myfolder\ has the same effect as using a mapping
to that same folder. Components can be organised into subdirectories and it
will work the same.


> Also, just to be clear on the names, what you have here (getCFC()) is a
> function, not a method. A function is standalone, while a method is
> invoked
> on an object.


Quite right to make the distinction, and my bad; though I should say that a
method belongs to or is part of an object rather than anything 'on' to one.

The solution is certainly small scale and it's benefit is in portability and
independant deployment with a small project for which it is not desirable to
have the end users (developers) have to set up a mapping each time they wish
to use it (if you can unzip something into a folder and have it working
straight away I say hoorah)!

It is also not desirable for use in calling components from within other
components (I missed this in the OP, just read the title and your reply)
although I'd say appliation.cfc MIGHT be an exception to this.

Anyways, apologies for all the inflammatory tones

Dominic

On 16/11/2007, Brian Kotek <[EMAIL PROTECTED]> wrote:

> What you've described is not the same as what the original poster is
> asking
> about. He want to use relative paths. You have created a simple factory,
> but
> you still have to either know the full path to the target CFC (which is
> not
> what he was wanting), or you have to have all your CFCs in a single folder
> (which is not very easy to deal with if you have many components).
>
> In any event, this simple factory might work fine if you have a simple
> object model with limited dependencies. But for any large object model, is
> very limiting since now any code using this has to be concerned about
> creating all the objects you will use, with the proper arguments and the
> proper dependencies resolved. ColdSpring solves all of these problems and
> you only have to declare the paths to the components in one place: the
> ColdSpring XML config file. Once that is done, you can use ColdSpring to
> inject the CFCs into other CFCs that need to use them, or you can just
> call
> getBean() on the ColdSpring bean factory to get back a reference to the
> component.
>
> Basically, instead of worrying about relative paths (for the original
> poster) or having other parts of your application burdened with the
> responsibility of properly creating the components and resolving their
> dependencies (for Dominic), just define their locations in one place and
> let
> ColdSpring do the work for you.
>
> Also, just to be clear on the names, what you have here (getCFC()) is a
> function, not a method. A function is standalone, while a method is
> invoked
> on an object.
>
> Hope this helps.
>
> Brian
>
>
> On Nov 16, 2007 10:48 AM, Dominic Watson <[EMAIL PROTECTED]>
> wrote:
>
> >
> > I don't see why this is 'hacking' it at all. I also came up with
> something
> > like this and I don't see why it is a problem. Indeed, our company does
> > not
> > host the websites that we create and removing any kind of responsibility
> > of
> > the system working from third parties is a bonus (we have to ask them to
> > setup any mappings we want on a server, if things go wrong it can delay
> > deployment 5 days or more).
> >
> > Could someone explain to me why I am wrong (this is a straight question
> > and
> > I quite expect to be convinced ;)?
> >
> > The udf I created looked something like this:
> >
> > <cffunction name="getCFC">
> >  <cfargument name="name">
> >  <cfargument name="method" default="init" required="false">
> >  <cfargument name="args" type="struct" required="false">
> >
> >  <cfset var argNames = StructKeyArray(arguments.args)>
> >  <cfset var i = 0>
> >  <cfinvoke component="#arguments.name#" method="#arguments.method#"
> > returnVariable="ret">
> >  <cfloop from="1" to="#arrayLen(argNames)#" index="i">
> >   <cfinvokeargument name="#argNames[i]#"
> > value="#arguments.args[argNames[i]]#">
> >  </cfloop>
> >  </cfinvoke>
> >
> >  <cfreturn ret>
> > </cffunction>
> >
> >
> > Just place the udf in a template in the same directory as your
> components
> > and load the method into the application scope. Then call the method
> when
> > ever you want to invoke a cfc, i.e.:
> >
> > <cfset myObj = application.getCFC("myCFC")> <!--- presuming myCFC.cfchas
> > a
> > method called init() that returns a value --->
> >
> >
>
>
> 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
ColdFusion 8 - Build next generation apps
today, with easy PDF and Ajax features - download now
http://download.macromedia.com/pub/labs/coldfusion/cf8_beta_whatsnew_052907.pdf

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:293523
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

Reply via email to