[ Pobierz całość w formacie PDF ]
.214931-6 ch17.F 7/18/02 7:00 AM Page 560Part III &' Incorporating Dynamic Data560Dreamweaver s ability to conditionally hide or reveal areas of the page is extremely helpfulfor smoothing the user experience.For example, suppose you have a Web application thatshows all 23 items in a particular recordset, five at a time with next and previous links, likethe one shown in Figure 17-5.The record navigation controls enable the user to page throughthe recordset, forward and backward.When they reach the final record, the Next and Lastbuttons should be hidden, and when they re on the first record, the previous and first but-tons should be hidden.I ve used the Show Region If Not Last Record to hide the next buttonand the Show Region If Not First Record to hide the previous button.Figure 17-5: Use Dreamweaver s Show Region server behavior to display or hidenavigation buttons depending on the dynamic data shown.To apply a Show Region server behavior, follow these steps:1.Select the page area you would like to conditionally show.2.From the Server Behaviors panel, choose Add and select one of the server behaviorsfrom the Show Record submenu.The dialog box for the specific Show Record serverbehavior you chose is displayed, like the one shown in Figure 17-6.The dialog boxesfor all the Show Record server behaviors are identical.3.From the Recordset list, select the recordset on which to base the Show Recordcondition.4.Click OK when you re done.214931-6 ch17.F 7/18/02 7:00 AM Page 561Chapter 17 &' Managing Data561Figure 17-6: To use a Show Record server behavior, all you need to do is choose arecordset.Typically, the Show Region server behaviors are used in pairs.Apply a Show Region If NotFirst Record server behavior to a Previous Record link this will hide the link when theuser is on the first record.Similarly, apply a Show Region If Not Last Record server behaviorto the Next Record link, which will cause the link to disappear when the last record is called.Only the first two Show Region server behaviors Show Region If Recordset Is Empty andShow Region If Recordset Is Not Empty may be applied to a page without any preconditions.The other four Show Region server behaviors require that one other type of server behaviorbe present on the page: the Recordset Paging server behavior.The Recordset Paging serverbehaviors act like VCR controls, adding a link that, when selected, displays the first, last,next, or previous set of records.The Recordset Paging server behaviors are covered in moredetail in the following section.CautionWhen adding any of the Show Region server behaviors to a table with a Repeat Regionserver behavior, you need to apply the Show Region server behavior to the repeated regionseparately.If, for example, your table has a header row and a repeating row, you would applythe Show Region server behavior twice: once to the header row and once to the row con-taining the Repeat Region server behavior.Tables without a Repeat Region may be condi-tionally shown with one Show Region server behavior.214931-6 ch17.F 7/18/02 7:00 AM Page 562Part III &' Incorporating Dynamic Data562Handling Record NavigationSo far in this chapter, you ve seen how to repeat dynamic data and how to make that data andother page elements programmatically be hidden or displayed.Now it s time to put some realinteractive controls into the hands of your Web application users.Dreamweaver includes aset of server behaviors that enable the user to page through your recordset, much like flip-ping the pages of a catalog.You can approach Dreamweaver s record navigation through two avenues: One option is a do-it-yourself route, whereas the other has Dreamweaver do most of the work for you.To betterunderstand how record navigation works, you ll examine the piece-by-piece approach first.Building record navigation linksAs mentioned in the previous section on Show Region server behaviors, Dreamweaver alsoincludes a set of server behaviors to control navigation within a recordset.Again, applicationis straightforward: Select the text or image you d like to serve as a trigger and attach the appro-priate server behavior.When selected, the trigger fires the server-side code that retrieves thechosen record.If a Repeat Region is inserted on the page, the next or previous group ofrecords is displayed.You can find five server behaviors under the Recordset Paging submenu:&' Move To First Record&' Move To Previous Record&' Move To Next Record&' Move To Last Record&' Move To Specific RecordNoteThe final Recordset Paging server behavior, Move To Specific Record, is most often used inconjunction with a search routine or a master-detail application.As noted, you can use either text or images as your controls.Navigation links, such as thoseshown in Figure 17-7, may even include rollovers or other client-side behaviors.You can evenuse Flash Buttons to trigger recordset navigation; see Dreamweaver Technique: Using FlashButtons for Recordset Navigation, later in this chapter, for a detailed explanation of how it sdone.You don t need to add an initial or placeholder link to your image or text.When the RecordsetTipPaging server behavior is applied, the link will be written for you.To create recordset navigation links, follow these steps:1.Select the text or image to which you d like to attach the server behavior.2.From the Server Behaviors panel, select Add, and choose the desired behavior fromthe Recordset Paging submenu.The appropriate Recordset Paging dialog box appears.If you ve made a selection, it s highlighted in the Link list; otherwise, a new text link iscreated, as shown in Figure 17-8.214931-6 ch17.F 7/18/02 7:00 AM Page 563Chapter 17 &' Managing Data563Figure 17-7: You can use images with or without rollovers to navigate through arecordset with Dreamweaver s Recordset Paging server behaviors.Figure 17-8: The Recordset Paging serverbehaviors identify your selected target,whether it is an image or text.3.Make sure that the link selected is the desired one in the Link list.4.Choose the recordset you want to work with from the Recordset drop-down list.5.Click OK when you re done.6.Repeat Steps 1 through 5 to add more recordset navigation elements.NoteRecord navigation is done within a particular recordset; you can t link from one recordset toanother using the Dreamweaver server behaviors or Application Objects.After you ve added your navigation controls, you may want to take the next step toward amore complete user interface by adding Show Region server behaviors to ensure that thecontrols are displayed only when they serve a purpose.For example, if you have a navigationelement that moves to the last record of a recordset, you probably want to attach a Show IfNot Last Record server behavior to the trigger.214931-6 ch17 [ Pobierz całość w formacie PDF ]