All of my cfc's have an init() method. Those for data access take an 
argument for the dsn and place it in the VARIABLES scope.

If you aren't intending to initialize your object, I guess you could 
have code, in each method, to check for hidden arguments?

<cfif IsDefined("ARGUMENTS.dsn")>
      <cfset VARIABLES.dsn = ARGUMENTS.dsn />
</cfif>

Not sure that it would be wise within an Ajax bind though, as you'd be 
passing the dsn to the method via an open http call. Probably a better 
option to use Coldspring or ColdBox to autowire those dependencies. 
Haven't really tested it yet.

Steve "Cutter" Blades
Adobe Certified Professional
Advanced Macromedia ColdFusion MX 7 Developer
_____________________________
http://blog.cutterscrossing.com

Morten Kruse wrote:
> How do you handle datasources inside CFC’s.
> until now I have just been using the variable application.dsn.
> 
> But I have been told that I should include the database name in the parameter 
> call to the cfc.
> 
> But I don’t want to call the cfc with the database name every single time 
> the cfc is called like:
>       <CFINVOKE COMPONENT="cfc.Meals" METHOD="getMeal" 
> dns="#application.dns#" />
> 
> Is it possible to invoke the whole component with the database information 
> and then call that instance without the dns?? 
> 
> 
> 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
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:291323
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4

Reply via email to