Elements of a ColdFusion application

Before you develop a ColdFusion application, you must determine how to structure the application and how to handle application-wide needs and issues. In particular, you must consider all of the following:

The following sections introduce these application elements and provide references to more detailed information.

The application framework

The application framework is the overall structure of the application and how your directory structure and application pages reflect that structure. You can use a single application framework to structure multiple ColdFusion applications into a single website or Internet application. You can structure a ColdFusion application using many methodologies. For example, the FuseBox application development methodology is one popular framework for developing ColdFusion web applications. (For more information on FuseBox, see http://www.fusebox.org.)

This chapter does not provide information on how to use or develop a specific application framework. However, it does discuss how an application's directory structure affects the application and how you can map the directory structure. For more information on mapping the application framework, see "Mapping an application".

Note:   For one example of an application framework, see "ColdFusion Methodologies for Content Management", available at http://www.macromedia.com/v1/handlers/index.cfm?ID=20750&method=full.

Application-level settings and functions

ColdFusion processes the following two pages, if they are available, every time it processes any page in the application:

Note:   UNIX systems are case-sensitive. To ensure that your pages work on UNIX, always capitalize the A in Application.cfm and the O, R, and E in OnRequestEnd.cfm.

The Application.cfm page provides a good place to define the application. It can contain the cfapplication tag that specifies the application name, and contains code that must be processed for all pages in the application. This page defines application-level settings, functions, and features.

Application-level features can include page processing settings, default variables, data sources, style settings, and other application-level constants, and application-specific custom error pages. When defined and set on the Application.cfm page, they are available on all pages in the application.

ColdFusion applications can have application-level variables that are not in the Application scope. For example, every page in an application might have a currentPage variable that identifies the page. The Application.cfm page can set this variable in the Variables scope, so each page gets a different, local value. Because every page in the application has the variable, it can be considered to be an application-level variable, even though it is not an Application scope variable.

The OnRequestEnd.cfm page is used in fewer applications than the Application.cfm page. It lets you provide common clean-up code that gets processed after all application pages.

For more information on the Application.cfm and OnRequestEnd.cfm pages, see "Creating the Application.cfm page". For information on placing these pages in the application directory structure, see "Mapping an application".

Note:   You can create a ColdFusion application without using Application.cfm or OnRequestEnd.cfm pages. However, it is much easier to use the Application.cfm page than to have each page in the application use a cfapplication tag and define common application elements.

Reusable application elements

ColdFusion provides a variety of reusable elements that you can use to provide commonly-used functionality and extend CFML. These elements include the following:

For an overview of these elements, and information about how to choose among them, see Chapter 8, "Reusing Code in ColdFusion Pages".

Shared variables

The following ColdFusion variable scopes maintain data that lasts beyond the scope of the current HTTP request:
Variable scope
Description
Session
Variables that are available for a single client browser for a single browser session in one application.
Client
Variables that are available for a single client browser over multiple browser sessions in one application.
Application
Variables that are available to all pages in an application for all clients.
Server
Variables that are available to all applications on a server and all clients.

For more information on using these variables, including how to use locks to ensure that the data they contain remains accurate, see Chapter 15, "Using Persistent Data and Locking".

Application security and user identification

All applications must ensure that malicious users cannot make improper use of their resources. Additionally, many applications require user identification, typically to control the portions of a site that the user can access, to control the operations that the user can perform, or to provide user-specific content. ColdFusion provides the following forms of application security to address these issues:

For more on implementing security, see Chapter 16, Securing Applications.

Comments