Accessibility
Raymond Camden

Raymond Camden

coldfusionjedi.com

Created:
22 December 2008
User Level:
Intermediate
Products:
Dreamweaver

Creating master and detail ColdFusion pages

Adobe Dreamweaver CS4 enables you to easily create master/detail ColdFusion pages. A master page is a page that lists database records and corresponding links for each record. When the user clicks a link, a detail page opens displaying more information about the record.

Requirements

In order to make the most of this article, you need the following software:

Dreamweaver CS4

Prerequisite knowledge

Familiarity with building dynamic sites in Dreamweaver.

Creating a master page

This section describes how to create a master page that lists database records. You can use a dynamic table to list the records on a ColdFusion page.

Before you start, make sure you define a ColdFusion data source for your database. For more information, see Database Connections for ColdFusion Developers in Dreamweaver Help.

To create a master page:

  1. In Dreamweaver CS4, create a new ColdFusion page. Choose File > New > ColdFusion, and click Create. A blank ColdFusion page opens in Dreamweaver CS4.
  2. Define a recordset for the page.

    In the Bindings panel, click the Plus (+) button, select Recordset (Query), and complete the Recordset dialog box. For more information, click the Help button on the dialog box. If you want to write your own SQL statement, click the Advanced button to open the advanced Recordset dialog box.

    Make sure the recordset contains all the table columns you need to create your dynamic table. The recordset must also include the table column containing the unique key of each record—that is, the record ID column. In Figure 1, the ARTISTID column contains information that uniquely identifies each record.

    The ARTISTID column contains information that uniquely identifies each record

    Figure 1. The ARTISTID column contains information that uniquely identifies each record.

    Typically, the recordset on the master page extracts a few columns from a database table while the recordset on the detail page extracts more columns from the same table to provide the extra detail. For now, though, simply use the default All columns selection.

    The recordset can be defined by the user at runtime. For more information, see Find and display the requested record on the detail page in Dreamweaver Help.

  3. Insert a Master Detail Page Set to both display the records on the page and create a detail page (see Figure 2).

    Insert a Master Detail Page Set to both display the records on the page.

    Figure 2. Insert a Master Detail Page Set to both display the records on the page.

    If prompted to save the file, save it as test.cfm. The Master Detail Page Set dialog box appears (see Figure 3).

    Select a few of the fields for the master page.

    Figure 3. Select a few of the fields for the master page.

    Select a few fields for the master page. Note that you can specify which field will have the link and what column from the recordset will be used in the link. Specify test_detail.cfm for the detail page name, and select whatever fields you want to display for the detail page. Finally click OK.

Viewing the completed pages

After uploading both the master and detail pages to the server, you can open the master page in a browser (see Figure 4).

The master page as it appears in a browser.

Figure 4. The master page as it appears in a browser.

After clicking the Donolan link on the master page, the detail page opens with more information about the record (see Figure 5).

The detail page contains more information about the record.

Figure 5. The detail page contains more information about the record.

Creative Commons License
This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License

About the author

Raymond Camden is a software consultant focusing on ColdFusion and RIA development. A long time ColdFusion user, Raymond has worked on numerous ColdFusion books including the ColdFusion Web Application Construction Kit and has contributed to the Fusion Authority Quarterly Update and the ColdFusion Developers Journal. He also presents at conferences and contributes to online webzines. He founded many community web sites including CFLib.org, ColdFusionPortal.org, ColdFusionCookbook.org and is the author of open source applications, including the popular BlogCFC (www.blogcfc.com) blogging application.Raymond can be reached at his blog (www.coldfusionjedi.com) or via email at ray@camdenfamily.com. He is the happily married proud father of three kids and is somewhat of a Star Wars nut.