>
> You can try to hack around it (
>
> http://www.bennadel.com/blog/348-Creating-ColdFusion-Components-In-Parent-Directories-From-Sub-Directories-Without-Mapped-Paths.htm
> ),
> but just do it correctly and create a CF mapping.
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.cfc has a
method called init() that returns a value --->
--
Blog it up: http://fusion.dominicwatson.co.uk
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Get the answers you are looking for on the ColdFusion Labs
Forum direct from active programmers and developers.
http://www.adobe.com/cfusion/webforums/forum/categories.cfm?forumid-72&catid=648
Archive:
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:293465
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe:
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4