A Basic Application.cfc Template

Take a look at Listing 19.1, a simple Application.cfc file. This example makes use of the onRequestStart method. Because the two <cfset> tags are executed before each page request, the dataSource and companyName variables can be referred to within any of the application’s ColdFusion templates. For instance, the value of the dataSource variable will always be ows.

If you save this listing, be sure to save it as Application.cfc, not Application1.cfc.

Listing 19.1. Application1.cfc—A Simple Application Template
<!--- Filename: Application.cfc (The "Application Component") Created by: Raymond Camden (ray@camdenfamily.com) Purpose: Sets "constant" variables and includes consistent header ---> <cfcomponent output="false"> ...

Get Adobe ColdFusion 8 Web Application Construction Kit, Volume 1: Getting Started now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.