Section 21.4. Recordset Navigation

21.4. Recordset Navigation

Dreamweaver's Repeating Region tool lets you display multiple database records on a single Web page. But a recordset with large amounts of datalike 1,000 employee recordscan quickly choke a Web page. A large amount of information takes a long time to download and forces visitors to scroll for many screens to see it all.

Fortunately, the tool also lets you limit the number of records displayed at once. Of course, this limit presents its own set of problems: how do visitors see additional records, and how do you let them know where they are among all the records in the recordset?

To solve this dilemma, Dreamweaver comes with two handy commands for adding navigation to a recordsetand providing useful feedback about the recordset.

FREQUENTLY ASKED QUESTION
A Little Less Repetition

I applied the Repeat Region object, and when I preview the page, the same record's repeated over and over. That's not what I wanted to do! What's going on ?

This can happen when you apply a Repeat Region object and inadvertently select the wrong recordset from the Repeat Region window (see Figure 21-12)a mistake that's easy to make if you've included more than one recordset on a page.

The Repeat Region object adds programming code that steps through each record of a recordset. So, in practice, the Repeat Region object should get the information from the first record in a recordset and write it to the Web page, then go to the second record and add its info to the page. This process should continue until it's either gone through all the records in the recordset or reached the limit specified in the "Records at a Time" box.

However, if the information you want repeated is retrieved by a different recordset from the one selected in the Repeat Region window, this system breaks down. Instead, the code continues to cycle through each record from the selected recordset, but doesn't cycle through each record from the recordset containing the dynamic information you want repeated. The result: you get the same information over and over again. The first record of the recordset (the one you want repeated) is repeated for each record in the other recordset (the one you don't want repeated).

In other words, to ensure that Repeat Region works, select the recordset whose data is contained in the area you want repeated .


21.4.1. Recordset Navigation Bar

Suppose a page contains a recordset that retrieves 100 records from a database, but the repeating region on the page limits the display to 10 records at a time. In this case, you should insert a Recordset Navigation Bar to add either text links or graphic buttons to a page. These navigation bars let your audience view the next 10 records in the recordset, jump to the last records in the recordset (see Figure 21-13), jump back to the first record, or move to previous records in the recordset.

Figure 21-13. Dreamweaver's Recordset Navigation Bar object prevents information overload by letting Web page visitors step through easily digested pages of information. The Recordset Status message also keeps visitors informed about how many records are available.

EXTENSION ALERT
Repeating Regions Left to Right and Top to Bottom

When you use the repeating region on a table row, you end up stacking each record on top of the next. While this successfully displays your records, it lacks pizzazz. Wouldn't it be great if you could list, say, a couple of records per row?

For example, say you've got a database of books. You could display titles and covers for three books from left to right across the page, and then add another row of three books below that one, and so on.

Dreamweaver can't do this out of the box, but you can turn to the creative army of programmers who write extensions add-on commands and functions (see Chapter 19 for more information on extensions). For the ASP, JSP, and PHP server models, download the free Horizontal Looper from www.tom-muck.com/extensions/help/HorizontalLooper/. A commercial product, MX Looper, provides support for ASP, ColdFusion, and PHP, as well as several cool ways of displaying repeating regions: www.interaktonline.com/Products/Dreamweaver-Extensions/MXLooper.


To add a Recordset Navigation bar, follow these steps:

  1. Click in the document window at the location where you want to insert the navigation bar. In the Application tab of the Insert bar, click the Recordset Paging button (see Figure 21-1) and then select Recordset Navigation Bar from the menu (see Figure 21-14) .

    You can also choose Insert Application Objects Recordset Paging Recordset Navigation Bar. In either case, the Recordset Navigation Bar window appears.

    Figure 21-14. The Recordset Paging button lets you insert a navigation bar for navigating the records returned in a recordset. In addition, if you want to build your own recordset navigation system, you can individually apply server behaviors like Move to First Record and Move to Next Record. These server behaviors are discussed on Section 23.3.
    FREQUENTLY ASKED QUESTION
    Behaviors That Serve You Well

    What's the difference between Dreamweaver Behaviors (Chapter 11) and a server behavior ?

    Both are prewritten programs created by Dreamweaver's engineers . They differ mainly in where the programs run and what they attempt to accomplish.

    A Dreamweaver Behavior is a JavaScript program that runs in a Web browser. It usually affects the interaction between a visitor and a Web page. For instance, the Swap Image behavior makes the Web browser exchange one image for another when a visitor mouses over a link. The behavior itself runs in the visitor's Web browser, and anyone can see the program by looking at the page's source code in the browser.

    A server behavior, on the other hand, always runs on the application serverthat is, on the Web-server side of the Internet. Instead of JavaScript, server behaviors can be written in a variety of different languagesVBScript, PHP, C#, Java, and so on, depending on the server model your site uses. Server behaviors specifically let you create connections to databases and display, edit, and delete information from databases. Furthermore, since these programs run on the application server, your site's visitors never see the actual programming code. All they see if they look at the source of the page is plain-old HTML (the results of the server program).

    In a nutshell , Dreamweaver Behaviors add interactive elements to a Web page, like rollovers and JavaScript alert boxes. Server behaviors supply the programming code you need to build sophisticated database-driven Web sites.


  2. From the Recordset menu, select the recordset to navigate .

    If the page contains more than one recordset, select the one that you used when you made the dynamic table or added the repeating region.

  3. Select whether to use text or graphic buttons for the navigation bar .

    If you select Text, Dreamweaver proposes the words First, Previous, Next, and Last to indicate the navigation controls. (You can edit them later.) The graphic buttons resemble standard VCR controls, representing forward and backward. If you select this option, Dreamweaver copies the four GIF files into the folder with the dynamic Web page. Later, you can replace these graphics with ones you create.

  4. Click OK to insert the navigation bar .

    Dreamweaver inserts a table, consisting of one row and four columns , into the document window. Each cell contains one text or graphic navigation button. You can change the alignment and any other property of the table to fit your design.


Tip: If you use the Recordset Navigation bar frequently, you may long to replace the VCR-control graphics that Dreamweaver displays. Just create your own graphics and name them FIRST.gif, LAST.gif, PREVI-OUS.gif, and NEXT.gif, and place them in the Dreamweaver 8 Configuration Shared UltraDev Images folder.

Here's how to add a Recordset Navigation Status message:

  1. Click in the document window at the location you want to insert the status message. In the Application tab of the Insert bar, click the Recordset Navigation Status button (see Figure 21-1) .

    You can also choose Insert Application Objects Display Record Count Recordset Navigation Status. In either case, the Recordset Navigation Status window appears.

  2. Click OK to close the window and insert the status message .

    The Recordset Navigation Status message is simply text with the three dynamic text items (see Section 21.2.1 for more on dynamic text). Change the words "Records," "to," and "of" to anything you like, such as in "Products 1-10. 149 total products retrieved."



Dreamweaver 8[c] The Missing Manual
Dreamweaver 8[c] The Missing Manual
ISBN: 596100566
EAN: N/A
Year: 2006
Pages: 233

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