Using Application Objects to Create an Admin Page

Team-Fly    

Macromedia® DreamWeaver® MX Unleashed
By Matthew Pizzi, Zak Ruvalcaba
Table of Contents
Chapter 29.  Modifying the Database


Aimed at giving you quick access to sophisticated interactivity without having to rely on the various panels that encompass all the objects, application objects are basically predesigned Web components that you can use within your application. Application objects are easy to use; in fact, you already used some of them and may not have even known it. Application objects include the following:

  • Recordset Launches the Recordset dialog box that you would normally receive when selecting the Recordset server behavior from the Bindings panel.

  • Dynamic Table Enables you to quickly create and format a table complete with bound data from your recordset on-the-fly.

  • Dynamic Text Creates dynamic text from your recordset on-the-fly.

  • Recordset Navigation Bar Inserts First, Last, Previous, and Next pagination server behaviors complete with the Show Region behavior attached.

  • Recordset Navigation Status Displays a status message for which record the user is on while paging.

  • Repeated Region Creates a repeated region for a dynamic table.

  • Master Detail Page Set Arguably the most widely used application object, the master detail page set allows a developer to create a low detail page that links to a second more detailed page for a particular record.

  • Record Insertion Form Enables you to quickly build a form, complete with form objects that you specify, that when submitted, inserts into a table within the database.

  • Record Update Form Similar to the Record Insertion Form application objects, the Record Update Form enables you to build a form, complete with bound form objects, that allows your users to modify information within the database.

Dynamic Tables

You can quickly begin building an administration page for the Web store using some of the application objects that come prebundled with Dreamweaver MX. An admin page is a good way of keeping track and viewing products within your site, as well as deleting unnecessary items that you may not want.

NOTE

The admin page is built under an ASP server model. If you have not already done so, you may want to download the support files from www.dreamweavermxunleashed.com.


You can begin building the admin page by following the steps outlined next:

  1. Create a new page by selecting New from the File menu. Select the Advanced tab and pick the WebStore template.

  2. You now want to build a new query for your new recordset. Launch Access, select Create Query in Design View, and insert the products and inventory tables in the designer.

  3. Rather than selecting all the records within the database, select ProductID, ProductName, and ProductCost from the products table and Quantity from the inventory table. The result is shown in Figure 29.47.

    Figure 29.47. Begin generating a new query by selecting fields from the products and inventory tables.

    graphics/29fig47.jpg

  4. Select SQL View from the View menu and copy the code. Save your query and close Access.

  5. Create a new recordset by selecting it from the Application Objects submenu. Click the Advanced button and paste in the SQL code as shown in Figure 29.48.

    Figure 29.48. Paste the code into the SQL box.

    graphics/29fig48.jpg

  6. Select OK.

  7. Insert a new form into the page. This will come in handy later when you include delete functionality into the admin page.

  8. Select Dynamic Table from the Application Objects submenu. The Dynamic Table dialog box appears. Figure 29.49 shows all the values that the table within the admin page will contain.

    Figure 29.49. The Dynamic Table dialog box enables you to enter values for the creation of a table with dynamic text.

    graphics/29fig49.jpg

  9. Select OK. The table is inserted into the workspace as shown in Figure 29.50. Make any necessary aesthetic adjustments.

    Figure 29.50. The table shows the dynamic text within table cells.

    graphics/29fig50.jpg

  10. Save your work as "admin.asp" and test it in the browser. The result will look similar to Figure 29.51.

    Figure 29.51. Five records are shown within the table.

    graphics/29fig51.jpg

The Recordset Navigation Bar

Now that you have a dynamic table with data, you can use the recordset navigation bar object to include pagination. Rather than inserting four separate paging server behaviors along with four separate Show Region server behaviors, you can use the recordset navigation bar to accomplish the task in a few simple clicks. To insert a recordset navigation bar, follow these steps:

  1. Place your cursor just below the dynamic table that you have just created and select Recordset Navigation Bar from the Application Objects submenu.

  2. The Recordset Navigation Bar dialog box appears, enabling you to choose the recordset. You can also choose to use text or images as your navigational items. The result is shown in Figure 29.52.

    Figure 29.52. Choose the recordset to page through.

    graphics/29fig52.jpg

  3. Figure 29.53 shows the navigation bar. Notice how all four navigational items are present. The Show Region server behaviors that are attached will cause these items to shift from being visible to invisible, depending on where you are within the recordset.

    Figure 29.53. The navigational bar is inserted into your workspace.

    graphics/29fig53.jpg

  4. Save your work and test it in the browser. The result will look similar to Figure 29.54. Notice that you are able to paginate five records at a time.

    Figure 29.54. You are now able to paginate five records at a time.

    graphics/29fig54.jpg

Deleting Records

Ordinarily you would not want to give your customers permission to delete their information. For the most part, that task should be left up to an administrator. Inserting a delete record functionality can be accomplished just as easily as the insert record or update record functionality was through the use of the Delete Record server behavior. The Delete Record server behavior enables you to add record deletion based on a form submit. To add the delete record functionality to the admin page, follow these steps:

  1. Add a new column into the table by right-clicking in the productID column and selecting Insert Column from the Table submenu.

  2. Insert a new button from the Form submenu directly into the new column, change the label to Delete, and the type to "None". The result is shown in Figure 29.55.

    Figure 29.55. Insert a Submit button labeled Delete into the new column.

    graphics/29fig55.jpg

  3. Select Delete Record from the Server Behaviors panel.

  4. The Delete Record dialog box enables you to choose a connection, a table to delete from, the recordset to delete the item from, the unique key column, the form in which the data is contained, and a page to redirect to after the delete has been processed. The result is shown in Figure 29.56.

    Figure 29.56. Insert the appropriate data into the Delete Record dialog box.

    graphics/29fig56.jpg

  5. Save your work and test the admin page in the browser. Navigate a few records and select Delete.

  6. Check the database to confirm the deletion.

Master Detail Page Set

The master detail page set application object is one of the most powerful objects built into Dreamweaver MX. The master detail page set enables you to create a single page with as many fields from the recordset as you like. You can make one of the items linkable to a detail page that exposes all the items for that record. The master detail page set is a great component to use when you do not want to expose all the fields within the recordset at once but instead, expose just a couple, allowing a user to see greater detail whenever the user wants by selecting a link. You can insert the master detail page set object by following the steps outlined next:

  1. Remove all the other behaviors and recordset from the Server Behaviors panel.

  2. Open Access and copy the SQL code from the previously created query that contained all the records from the products and inventory tables. Close Access.

  3. Create a new recordset within Dreamweaver MX with the code that you just copied.

  4. Place your cursor in the Content editable region and select the Master Detail Page Set from the Application Objects submenu.

  5. The Insert Master Detail Page Set dialog box appears. The dialog box enables you to choose a Recordset, data to appear within the master page, the item you want linkable, the unique key to pass to the new page, how many records to show at a given time, the name of the detail page, and the fields to include within the detail page. The results are shown in Figure 29.57.

    Figure 29.57. Insert the appropriate data within the Insert Master Detail Page Set dialog box.

    graphics/29fig57.jpg

  6. Select OK. You will be taken immediately to the detail page as shown in Figure 29.58. Format the table accordingly. Save the page.

    Figure 29.58. The detail page shows all the records that you specified to appear within it.

    graphics/29fig58.jpg

  7. Switch back to the admin.asp page and format that page accordingly. Notice that a dynamic table along with a navigation bar and status are inserted for you. The result is shown in Figure 29.59.

    Figure 29.59. The Master page includes a dynamic table, a navigation bar, and the navigation status.

    graphics/29fig59.jpg

  8. Save your work and test it in the browser. Selecting the ProductID will link you to the detail page for that specific item.


    Team-Fly    
    Top


    Macromedia Dreamweaver MX Unleashed
    Macromedia Dreamweaver MX 2004 Unleashed
    ISBN: 0672326310
    EAN: 2147483647
    Year: 2002
    Pages: 321

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