Using Application Objects to Create an Admin Page
Aimed at giving you quick access to sophisticated interactivity without having to rely on the various panels that
all the objects, application objects are basically predesigned Web
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:
Launches the Recordset dialog box that you would normally receive when selecting the Recordset server behavior from the Bindings panel.
Enables you to quickly create and format a table complete with bound data from your recordset
Creates dynamic text from your recordset on-the-fly.
Recordset Navigation Bar
First, Last, Previous, and
pagination server behaviors complete with the Show Region behavior attached.
Recordset Navigation Status
Displays a status message for which record the
is on while paging.
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.
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.
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:
Create a new page by selecting New from the File menu. Select the Advanced tab and pick the WebStore template.
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.
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.
Select SQL View from the View menu and copy the code. Save your query and close Access.
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.
Insert a new form into the page. This will come in handy later when you include delete functionality into the admin page.
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.
Select OK. The table is inserted into the workspace as shown in Figure 29.50. Make any necessary
Figure 29.50. The table shows the dynamic text within table
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.
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:
Place your cursor just below the dynamic table that you have just created and select Recordset Navigation Bar from the Application Objects submenu.
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.
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.
Save your work and test it in the browser. The result will look similar to Figure 29.54. Notice that you are able to
five records at a time.
Figure 29.54. You are now able to paginate five records at a time.
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:
Add a new column into the table by right-clicking in the productID column and selecting Insert Column from the Table submenu.
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.
Select Delete Record from the Server Behaviors panel.
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
. The result is shown in Figure 29.56.
Figure 29.56. Insert the appropriate data into the Delete Record dialog box.
Save your work and test the admin page in the browser. Navigate a few records and select Delete.
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:
Remove all the other behaviors and recordset from the Server Behaviors panel.
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.
Create a new recordset within Dreamweaver MX with the code that you just
Place your cursor in the Content editable region and select the Master Detail Page Set from the Application Objects submenu.
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
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.
Select OK. You will be taken immediately to the detail page as shown in Figure 29.58. Format the table
. Save the page.
Figure 29.58. The detail page shows all the records that you specified to appear within it.
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.
Save your work and test it in the browser. Selecting the ProductID will link you to the detail page for that specific item.