Use Application.cfm to Make Your Code Faster and More Portable


Use Application.cfm to Make Your Code Faster and More Portable

Submitted by Dave Hannum, hannum@ohio.edu

Using the Application.cfm file in your applications can make them extremely powerful and portable. Think of it as a configuration file. For example, it seems that every system administrator has his own "right" way of configuring and laying out the directory structures of the servers he administers. Utilizing your Application.cfm file, you can move from machine to machine relatively painlessly. In the Application.cfm script, set the DATASOURCE, URL, and PHYSICAL PATH in REQUEST scope variables.

 <CFSET REQUEST.myURL = "http://www.myapp.com">  <CFSET REQUEST.myPATH = "c:\inetpub\wwwroot\clients\myapp">  <CFSET REQUEST.myDATASOURCE = "myappData"> 

Then, when you want to use the application on a different machine, you only need to change these three variable values in the Application.cfm file, and your application will run. Using the REQUEST scope makes these values available to any modules, custom tags, and so on. You can also go even more granular with, say, the URL to your start page and so on. Set variables in Application.cfm to easily account for time-zone differences. Also, use SESSION or APPLICATION scope variables in conjunction with the IsDefined() functions in Application.cfm to set variables that require a call to your database. You can speed up your application significantly by avoiding unnecessary calls to the database if you store values in SESSION or APPLICATION scope variables to be used in your application.



Inside ColdFusion MX
Inside Coldfusion MX
ISBN: 0735713049
EAN: 2147483647
Year: 2005
Pages: 579

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net