Share this Page URL

Chapter 16. Introducing the Web Applicat... > Using Locks to Protect Against Race ... - Pg. 368

Introducing the Web Application Framework 3. 4. 368 The ListGetAt() function is used to get the first movie's ID from the list. The value is placed in the ThisMovieID variable. This is the movie to feature on the page. Finally, the ListDeleteAt() function is used to chop off the first movie ID from the APPLI- CATION.MovieList variable. The variable now holds one fewer movie. Eventually, its length will dwindle to zero, in which case step 2 will occur again, repeating the cycle. Because you are interested in the first element in the list, you could use ListFirst() in place of the ListGetAt() function shown in Listing 16.11, if that reads more clearly for you. You also could use ListRest() instead of the ListDeleteAt() function. TIP See Appendix B for details. Now that the movie to feature has been picked (it's in the ThisMovieID variable), actually dis- playing the movie's name and other information is straightforward. The <CFQUERY> in the second half of Listing 16.12 selects the necessary information from the database, and then a simple HTML table is used to display the movie in a nicely formatted box. At this point, Listing 16.12 can be visited on its own, but it really was meant to show the featured movie on Orange Whip's home page. Simply include the template using the <CFINCLUDE> tag, as shown in Listing 16.13. Figure 16.5 shows the results. Example 16.13. Index2.cfm --Including the Featured Movie in the Company's Home Page <!--- Filename: Created by: Index.cfm Nate Weiss (NMW)