Accessibility

Table of Contents

Using CFMX7 Extensions for Dreamweaver MX 2004 – Part 2: Creating and Managing CFC Queries

How to Create a cfcquery: The New Way

In regards to query reuse, the CFMX7 Extensions enhancements are based on the fact that Dreamweaver is a WYSIWYG web editor for static and dynamic pages. Working with reused queries from ColdFusion shouldn't be an exception. Therefore, the goal was to retain every aspect of this best-practice visual and make sure everything is done right. I first cover the creation of the recordset; the embedded queries will have a name cfquery from now on.

To create a cfcquery, you must follow these steps:

  1. Create a new component by clicking the Plus (+) button in the Components tab. If the Components tab is not visible, you can open it by selecting Window > Components, or by pressing Control+F7.
  2. Fill in the component's name, hint, folder, and all other properties needed.
  3. Click OK to display the component in the Dreamweaver Code view.
  4. You must have at least one valid data source for your ColdFusion server. If you do not have one, create it from the database panel by clicking the Plus (+) button and configuring the interface, as explained in Part 1.
  5. Add a new recordset to the CFC page. To do so, click the Plus (+) button in the Bindings tab. If it is not visible, open it by selecting Window > Bindings.
  6. Fill in the user interface as you would do for any regular recordset (see Figure 3).

    Recordset dialog box with supplemental options

    Figure 3. Recordset dialog box with supplemental options

    As you might have already noticed, there are some new things that must be taken into account: the Function pop-up menu and the New Function button:

    • In the Function pop-up menu, all functions already defined in the active component are displayed. You can choose one of the functions to which the recordset will be attached.
    • The New Function button creates a new function in the active component; the only parameter required is the function name (see Figure 4).

      New function dialog box

      Figure 4. New function dialog box

  7. When you select a function from the pop-up menu, or a new one is defined, all parameters except the function name are automatically filled in with the following values:

    • Output is set to false
    • Returntype is set to query
    • Access is public
  8. The recordset creation part is done in the usual manner, either in simple or advanced mode.
  9. When you click OK, the cfquery is saved at the end of the selected function.

This way you didn't have to remember any data source or table names, or write any code into a plain component file. All of this was done through the Dreamweaver visual interfaces. As you will see next, the code inside the component is standard cfquery code (see Figure 5).

Code generated by the CFC Recordset interface

Figure 5. Code generated by the CFC Recordset interface

(+) View larger

This new visual approach reduces the recordset creation time and prevents code errors due to spelling mishaps in data sources or table names.

In this section you've learned what CFMX7 Extensions did in order to transform the cfcquery creation process into a simpler, visual process. In the next section you will find out what improvements CFMX7 Extensions brings when it comes to using them in your CFM pages.