Chapter 3: Introducing ColdFusion MX Application Development


A ColdFusion application consists of one or more ColdFusion pages that work together and share common resources. All pages in the application share the variables that are defined in the application scope. The pages that are common to any application should have the same basic layout. For example, the navigation scheme should be the same for all the pages in an application. Usually, pages of a single application use the same data source, style sheets, and login mechanism.

This chapter describes the components of a ColdFusion application, along with the tools that are used to create them.

Overview of the Components of a ColdFusion MX Application

All the pages of the application should give the end user a similar look and feel. These pages should also share a common general purpose. Before developing an application, it's important for you to determine the structure of the application and resolve any application-wide issues. Consider these points before developing an application:

  • The overall application framework

  • Application-level settings and functions

  • Reusable application elements

  • Shared variables

  • Application security

The Overall Application Framework

This is the overall structure of the application and is reflected in the structure of the directory and the application's pages. You can use a variety of methodologies to structure a ColdFusion application.

One such example is the Fuse Box application development methodology. This is based on the premise that a well-designed application is similar to the fuse box in a house. Each fuse has a defined job and works as an independent module. If one fuse blows, the others still continue to work. Similarly, if one section of a Fuse Box application breaks down, the rest of it continues to work.

Application-Level Settings and Functions

ColdFusion processes Application.cfm and OnRequestEnd.cfm pages every time it processes a page in the application. While Application.cfm is processed prior to processing a page, OnRequestEnd.cfm is processed after the page has been processed.

Application.cfm is the page where the name of an application is defined by the <CFAPPLICATION> tag. This page also contains code that must be processed for all pages in an application. Application-level settings, functions, and features are also defined on this page. Application-level features can include page-processing settings, default variables, data sources, style settings, and other application-specific pages. When they're defined on Application.cfm, they're available for all pages in the application.

ColdFusion applications can also have application-level variables that are not defined in the application scope. For example, every page may be identified by the numberPage variable. Although each page is assigned a different local value, this variable may be set in Application.cfm. This application-level variable isn't an application scope variable.

OnRequestEnd.cfm provides a common code that's processed after all application pages. It's an optional template. It should reside in the same directory as the caller template, which is the template that calls OnRequestEnd.cfm. ColdFusion does not search beyond this directory.

OnRequestEnd.cfm doesn't run if there's an error or an exception on the caller template. Also, it may not run if the caller template executes the <CFABORT> or <CFEXIT> tag.

Note

A ColdFusion application can be created without using Application.cfm or OnRequestEnd.cfm pages. A <CFAPPLICATION> tag is used on each page to define common application elements. This is a cumbersome procedure, though.

Before developing an application, you must establish a root directory for it. Application pages can be stored in subdirectories of this root directory. Mapping the directory structure is an important step in designing a ColdFusion application.

Reusable Application Elements

ColdFusion allows you to access a variety of reusable elements. These can be CFML custom tags, User-Defined Functions (UDFs), CFX tags, and pages that you can include using the <CFINCLUDE> tag. The UDFs should be used to code the application logic that can be repeatedly called from the different pages of the application. The ColdFusion components should be used to create Web services, which applications that are residing on different servers can use. The custom tags should be used to build a programmer's library for reusable code, which other programmers can use.

Shared Variables

Chapter 2, "Overview of CFML," discussed the scope of shared variables such as client, session, application, and server. You may recall that client variables are available for a single-client browser over multiple browser sessions in one application.

Application Security

Most applications require end user authentication to control operations that can be performed by the end user or to restrict specific portions of the content. ColdFusion provides tags such as <CFLOGIN> and <CFLOGINUSER> to implement security considerations. The issues pertaining to security will be dealt with in Chapter 6, "Implementing Security in ColdFusion Applications."




Macromedia ColdFusion MX. Professional Projects
ColdFusion MX Professional Projects
ISBN: 1592000126
EAN: 2147483647
Year: 2002
Pages: 200

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