This article explains the Application Panel in Dreamweaver MX.
It is part from the book Dynamic Dreamweaver MX written by many famous people including our own Omar Elbaga from the UDzone team!
This article explains the Application Panel in Dreamweaver MX.
It is part from the book Dynamic Dreamweaver MX written by many famous people including our own Omar Elbaga from the UDzone team!
So far we have displayed our categories dynamically. When a category is clicked the user is taken to a complete list of all books associated with the respective category. Thus far we only have 20 different records to display in total - this is easy to deal with, but what about in future, when we want to display lots more? Also bear in mind that when we add the thumbnail images, they will increase the page loading time even further, so it will eventually become unmanageable to display all the records for each category every time.
So what if we wanted to remedy this by say, displaying 4 records at a time? This is all no problem at all - that's what the Recordset Paging set of behaviors is for.
Let's make some adjustments to our books.asp page by having only 4 records display at a time. Before we go any further we have to edit our repeat region. Double-click the Repeat Region behavior listed in the Server Behaviors list from the Application Panel. This will re-open the dialog box that selects our Repeat Region parameters. Instead of showing all records check the radio button above it and show 4 records at a time. Hit OK.
Place your cursor in a suitable place (we chose a place in the second column of the first row of your table) and select Server Behaviors > + > Recordset Paging > Move To Previous Record, which should bring up the following dialog box:
Leave the value for the Link field the way it is; it will create the text for us. Make sure the rsBooks recordset is selected in the Recordset field and hit OK. The Previous hyperlink will be added to your page where you put your cursor.
Choose another suitable space (we chose a space just to the right of the Previous hyperlink) and select Server Behaviors > + > Recordset Paging > Move To Next Record, and click OK. A Next hyperlink will be added to the right of our Previous hyperlink.
Before we view the page in our browser, let's use an Application Object called the Recordset Navigation Status. This object creates a display of how many records exist and how many are being displayed currently. It shows the user where he or she is in the context of all the records collectively. Before we add it, let's make some room for it by adding a third row above the row that contains the Previous and Next links. Do this by placing your cursor in the first row, right-clicking, and selecting Table > Insert Row - an empty row should be created above the other two.
Now that we have created the empty row place your cursor in the second column of the first row. Select Insert > Application Objects > Recordset Navigation Status, and OK the dialog box that appears, to add the object to our page. Now when we view the books.asp page in a browser we should see something like this:
Although the page looks great, there is one slight problem that needs fixing - did you notice it? The problem is that when you get to the detail page, the Previous hyperlink is displayed even though there are no previous records (when records 1-4 are displayed). In addition, when you scroll through the records and get to records 12-16, the last group of records, the Next hyperlink is still displayed.
What we really want to happen is for the Previous link to show only if you are not at the first record, and the Next link to show only if you are not at the last record. Well guess what? Dreamweaver MX has another group of server behaviors that do this for us! They can be found under Server Behaviors > + > Show Region.
Show Region contains a set of server behaviors that allow you to show regions of your document based on a few conditions. In our application, we'll utilize two, to sort out the problems discussed above:
Highlight the Previous hyperlink that was generated by the Move to Previous Record behavior. Select Server Behaviors > + > Show Region > Show Region If Not First Record, and OK the box that appears.
Highlight the Next hyperlink that was generated by the Move to Next Record behavior. Select Server Behaviors > + > Show Region > Show Region If Not First Record, and OK the box that appears.
Now view the books.asp page in a browser, and you should see that the Previous hyperlink does not appear until you get to the second group of records. Similarly the Next hyperlink does not appear when you get to the last group of records.
Before we move onto another server behavior, I am going to show you something else Dreamweaver MX can do for you. Think about how many steps it took to implement the recordset Paging - we had to work with four different server behaviors: Move To Previous Record, Move To Next Record, Show Region If Not First Record, and Show Region If Not Last Record.
Brace yourself...we could've done this in one step using the Recordset Navigation Bar object! It can be found under Insert > Application Objects. This object utilizes the same server behaviors we used before, but selecting it inserts fully functional First, Previous, Next, and Last hyperlinks - instantly.
Dreamweaver MX has some other Application Objects that save us extra steps, as we shall see later. However, I want you to be able to use the server behaviors individually before using the additional timesaving Application Objects, to aid your understanding - I hope you forgive me!
Now let's continue our look at the Show Region behaviors.
There may be some instances where a recordset comes up empty meaning it has retrieved no records based on the query. I left one of the categories empty so that I can demonstrate this server behavior for you.
If you click on the World Literature category on your master page you will see that the detail page is empty because there are no books associated with this category. If this were a real-world application, you would most likely want to display a message when a query comes up empty. For example, you might display, "Sorry, no records found. Please go back and select another category." Without further ado, let's do that now.
Before we add the server behavior let's add the text, "Sorry, no records found. Please go back and select another category." Add another row above the other rows in your table. You should now have an empty first row. Place your cursor in the second column of this row and type your message there. Highlight the row by selecting the <tr> tag from the page status bar while your cursor is in the row. Select Server Behaviors > + > Show Region > Show Region If Recordset Is Empty.
View your page live now by loading the categories3.asp page. Select the World Literature category. You should see your message displayed because the recordset will be empty.
There is another issue on the page that calls for the use of another server behavior. I don't know about you but I think it looks a bit messy having the rest of the table showing but empty when the records come up empty. If you don't mind you can leave it, but we can easily hide it when the recordset is empty like so:
Return to your document in Dreamweaver MX and highlight the second row of the table. Select Server Behaviors > + > Show Region > Show Region If Recordset Is Not Empty. Repeat this process for the third row of the table. Now if you view the page in a browser, the rest of the table should not display when the recordset on the detail page is empty.
So far we have learned how to:
· Create recordsets to retrieve database records
· Display database records dynamically on our web pages
· Filter recordsets by parameters passed and show and hide regions based on conditions
It would be great if we could now add a system to allow us to update our data without having to manually go into our database to do so - create a web application with Dreamweaver MX that will allow us to insert, update, and delete database records.
George Petrov is a renowned software writer and developer whose extensive skills brought numerous extensions, articles and knowledge to the DMXzone- the online community for professional Adobe Dreamweaver users. The most popular for its over high-quality Dreamweaver extensions and templates.
George is also the founder of Wappler.io - the most Advanced Web & App Builder
Comments
Hello to everybody
textsing
RE: Hello to everybody
You must me logged in to write a comment.