You might want to look at a suggested CFMX OOP design pattern posted
under the ColdFusion topic on http://www.benorama.com. I've been
experimenting with this recently and find it to be very clean and effective.
Cutter
Li Chunshen (Don) wrote:
>According to Macromedia's CFMX References on Using
>UDFs effectively:
>
>"Consider the following techniques for making your
>functions available to your ColdFusion pages:
>
>If you consistently call a small number of UDFs,
>consider putting their definitions on the
>Application.cfm page.
>If you call UDFs in only a few of your application
>pages, do not include their definitions in
>Application.cfm.
>If you use many UDFs, put their definitions on one or
>more ColdFusion pages that contain only UDFs. You can
>include the UDF definition page in any page that calls
>the UDFs. "
>
>I agree with everything it states, and I think it
>might help more if CFMX predefines a UDF library path
>such as UDFlib under CFMX installation instead of an
>arbitrary directory, I can see several benefits of
>this approach:
>consistency -- especially helpful for large
>development environment;
>easier for reuse -- across applications/projects
>(this one is similar to CFMODULE's dot notation
>method, I love it)
>
>And I don't see any downside of it. Thanks.
>
>DL
>
>
>--- Matthew Walker <[EMAIL PROTECTED]> wrote:
>
>
>>These two cfmx UDFs from cflib.org may help:
>>
>>
>><cfscript>
>> function DSNExists(DSN) {
>> var factory =
>>
>>
>>
>createObject("java","coldfusion.server.ServiceFactory");
>
>
>> var DSNs =
>>factory.getDataSourceService().getNames();
>> return
>>yesNoFormat(listFindNoCase(arrayToList(DSNs),
>>DSN));
>> }
>></cfscript>
>>
>>
>><!---
>> Verifies a DSN is working.
>>
>> @param dsn Name of a DSN you want to verify.
>>(Required)
>> @return Returns a Boolean.
>> @author Ben Forta ([EMAIL PROTECTED])
>> @version 1, October 15, 2002
>>--->
>><CFFUNCTION NAME="VerifyDSN" RETURNTYPE="boolean">
>> <CFARGUMENT NAME="dsn" TYPE="string"
>>REQUIRED="yes">
>>
>> <!--- initialize variables --->
>> <CFSET var dsService="">
>> <!--- Try/catch block, throws errors if bad DSN
>>--->
>> <CFSET var result="true">
>>
>>
>> <CFTRY>
>> <!--- Get "factory" --->
>> <CFOBJECT ACTION="CREATE"
>> TYPE="JAVA"
>>
>>CLASS="coldfusion.server.ServiceFactory"
>> NAME="factory">
>> <!--- Get datasource service --->
>> <CFSET
>>dsService=factory.getDataSourceService()>
>> <!--- Validate DSN --->
>> <CFSET result=dsService.verifyDatasource(dsn)>
>>
>> <!--- If any error, return FALSE --->
>> <CFCATCH TYPE="any">
>> <CFSET result="false">
>> </CFCATCH>
>> </CFTRY>
>>
>> <CFRETURN result>
>></CFFUNCTION>
>>
>>
>>
>>>-----Original Message-----
>>>From: Li Chunshen (Don) [mailto:[EMAIL PROTECTED]]
>>>Sent: Wednesday, 1 January 2003 11:37 a.m.
>>>To: CF-Talk
>>>Subject: Request Time
>>>
>>>
>>>specs: CFMX on WinXP Pro; remote datasources on
>>>
>>>
>>Win2k
>>
>>
>>>Pro.
>>>
>>>Requestimeout set to 40 seconds via CF admin
>>>
>>>
>>(server
>>
>>
>>>has been rebooted, my friend). Expect cf server
>>>
>>>
>>to
>>
>>
>>>throw requestimeout msg, better, gracefully,
>>>regardless of the types of request. Problem, when
>>>trying to connect to an unavailable remote
>>>
>>>
>>datasource
>>
>>
>>>(who can garanttee it's always available?),
>>>
>>>
>>instead
>>
>>
>>>of 40 seconds timeout, CFMX keeps on trying and
>>>
>>>
>>trying
>>
>>
>>>though asked otherwise, what's going on? With
>>>
>>>
>>CF5, an
>>
>>
>>>undocumented tag of Is_CFdatasource takes care of
>>>
>>>
>>the
>>
>>
>>>problem very well. Thanks.
>>>
>>>DL
>>>
>>>
>>>
>>>
>>>
>>>__________________________________________________
>>>Do you Yahoo!?
>>>Yahoo! Mail Plus - Powerful. Affordable. Sign up
>>>
>>>
>>now.
>>
>>
>>>http://mailplus.yahoo.com
>>>
>>>
>>>
>
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription:
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Structure your ColdFusion code with Fusebox. Get the official book at
http://www.fusionauthority.com/bkinfo.cfm