|
Depending on what’s in the CFC, you could write an init() that did something like, say, stored the datasource name, user, and password, so the CFC doesn’t touch any other scopes (which is a good practice). Something like so may work:
<cfset utilityCFC = CreateObject( “component”, “myGlobalCFC” ).init( application.dsn, application.dsnusername, application.dsnpassword ) />
and your init() would look like so:
<cffunction name=”init” returnType=”myGlobalCFC”> <cfargument name=”dsn” /> <cfargument name=”dsnusername” /> <cfargument name=”dsnpassword” />
<cfset Variables.dsn = arguments.dsnusername /> <cfset Variables.dsnusername = arguments. dsnusername /> <cfset Variables.dsnpassword = arguments. dsnpassword />
<cfreturn this /> </cffunction>
Just an idea. It would probably depend on what you’re doing in the CFC, and if this suits your style of coding utility libraries.
Hth
Nolan Erck -----Original Message-----
Ok, I think I figured this out. I think I don’t need an init function, since all I’m doing is creating a library of functions, not some cohesive object. However, if I’m wrong in this assessment, I would love to hear suggestions.
I can save the CFC in the CustomTags folder of my server and thus just reference the CFC by name.
It was nice talking to myself here. J Cheers, Ali
From: Ali Awan
[mailto:[EMAIL PROTECTED]
I’ve been lurking on this list for quite a while now, and I feel pretty embarrassed for asking such an elementary question.
I’m thinking of creating a sort of UDF library that can be used by all my apps. Does it make sense to create a Component that holds all the functions? In such a case, what would an init function hold. For example, if I have a bunch of generic Validation functions, would I need an init function for the CFC? If so, what would it look like?
Also, where would I need to put the CFC on the server so that it is accessible to all my apps? I’m thinking along the lines of custom tags, where we could just put them in the CustomTags folder and they are accessible to all.
Is there such a folder for CFC’s?
Thanks, Ali The information contained in this e-mail is confidential and may contain privileged information exempt from disclosure under applicable law. The information is intended only for the use of the individual or entity to which it is addressed. If you are not the intended recipient, employee, or agent responsible to deliver it to the intended recipient, you are hereby notified that any use, dissemination, distribution, or copying of this communication is strictly prohibited. If you have received this e-mail in error, please delete the message from your computer and immediately notify the sender by telephone (you may call collect) at 916-569-5400 or by e-mail to [EMAIL PROTECTED] Thank you.
---------------------------------------------------------- |
- RE: [CFCDev] global cfc's Nolan Erck
- RE: [CFCDev] global cfc's Ben Rogers
- RE: [CFCDev] global cfc's Ali Awan
