Mapping an Application in a Directory Structure


As discussed earlier, when you design a ColdFusion application, you need to map its directory structure. Establish a root directory for the application before you start building it. The application pages can be stored in subdirectories of the root directory.

Mapping Application.cfm and OnRequestEnd.cfm pages in a directory structure is based on how ColdFusion processes these pages. The rules for locating and processing these pages vary.

These are the rules for locating and processing Application.cfm pages:

  • ColdFusion processes only one Application.cfm page for each request. First it looks for the Application.cfm page in the application page directory. If it's not there, ColdFusion searches up the directory tree until it finds an Application.cfm page.

  • If several directories in the directory tree have an Application.cfm page, ColdFusion uses the first page it finds.

  • If a page has a <CFINCLUDE> tag pointing to an additional page, ColdFusion won't search for an Application.cfm page when it includes this additional page.

  • On the Unix platform, the "A" in Application.cfm must be capitalized.

As mentioned earlier, the OnRequestEnd.cfm page runs after each application page. These are the rules of locating and processing the OnRequestEnd.cfm pages:

  • OnRequestEnd.cfm must be in the same directory as the Application.cfm that ColdFusion uses for the current page. ColdFusion won't run an OnRequestEnd.cfm page residing in another directory.

  • OnRequestEnd.cfm doesn't run if there's an error or exception on the application page.

These are the advantages of defining an application directory structure with an application-specific root directory:

  • Easy development and maintenance. The application is easier to develop and maintain because application page files are better organized.

  • Application portability. You can move the application to another server or another part of a server without altering the application page files.

  • Application-level settings. Application pages under the same directory can share application-level settings and functions.

  • Security settings. Security application pages under the same directory can share Web server security settings.

  • Flexibility in use of Application.cfm page. You can divide your Web application into multiple ColdFusion applications by using multiple Application.cfm pages with different application names. By placing your application in an application-specific directory hierarchy, you can use a single Application.cfm page in the application root directory. Alternately, you can put a number of Application.cfm pages that govern individual sections of the application in different directories.




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