Creating an Application Framework

Team-Fly    

ColdFusion® MX: From Static to Dynamic in 10 Steps
By Barry Moore
Table of Contents
Step 8.  ColdFusion Application Framework


So far, our web pages share a common look and feel, but that is about all. For our web site to become a true dynamic web application, we need to tie all our pages together with some kind of glue. That glue is known as an application framework. This application framework lets all our pages know that they are part of the same application. In addition, it gives us the capability to share common global settings among all the pages in our application without having to pass those values manually via FORM or URL variables.

An application framework begins with the organization of the directory structure. An application begins with a root folder, such as our NewSite folder, and all files and folders beneath that root folder are usually part of the same application.

Subdirectories below the root folder typically are used to organize the site into logical sections based on file type or function. For example, in our NewSite directory, we have put all of our included files into a subdirectory called _includes, and we have put all our online catalog pages into the products subdirectory. After we have our web site organized into these logical sections, we can begin to control these individual sections, or the web site as a whole, using the various techniques discussed in this step.

Another part of the application framework involves the use of two special ColdFusion templates called Application.cfm and OnRequestEnd.com. These templates can be automatically included before and after each and every page request that is made, as illustrated in Figure 8.1.

Figure 8.1. An application page request.

graphics/08fig01.gif

ColdFusion will process these two templates (if they are available) anytime a page in our site is requested. This makes the templates a great location to store global variable values that we would like to share across many pages in our application. Let's take a closer look at each of these two templates.


    Team-Fly    
    Top
     



    ColdFusion MX. From Static to Dynamic in 10 Steps
    ColdFusion MX: From Static to Dynamic in 10 Steps
    ISBN: 0735712964
    EAN: 2147483647
    Year: 2002
    Pages: 140
    Authors: Barry Moore

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