Dreamweaver MX - The Application Panel

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!

Repeat Region

Although our recordset does in fact retrieve all the records from our categories table, it will not automatically display all the records. When you try to display the database columns, ASP will display the first record retrieved. In order to display all records in the table we must loop through the records (recall "Looping Logic" from Chapter 5). Fortunately, there is a server behavior that does this for us, called Repeat Region. This server behavior will generate the ASP code necessary to loop through our records. Now that we have dragged the variables onto our page, we must add a repeat region behavior to the dynamic texts.

We should first select the area that we want repeated. Select the dynamic text in the left column, hold shift and select the dynamic text on the right. This will highlight the second row of the table, which is what we want to repeat. If this does not work for you, place your cursor in the second row and select the <tr> tag from the status bar towards the bottom of the document. Click the plus sign (+) from the Server Behaviors tab and select Repeat Region - OK the Repeat Region dialog box that pops up, as it is fine for what we want here. View the page in your browser, and it should look something like this:

We have displayed our categories dynamically from our database. We created a recordset to retrieve the records, and then we created an HTML table and placed the dynamic text into the table columns, adding a repeat region behavior to display all the records.

It didn't take too long to do this, but Dreamweaver MX has another feature that can save us even more time! It is called the Dynamic Table Object. You can find it by going to Insert > Application Objects, and its icon can be found under the Application tab in the Insert toolbar at the top of the display. Using it, you can recreate the page we just created but with only 2 steps. Let's do that now.

Create a new dynamic ASP web page and save it as dynamic_table.asp. We must create the same recordset we created in the first example. Name the recordset rsCategories. After creating the recordset, place your cursor in the document where you want to place your dynamic table and select Insert > Application Objects > Dynamic Table. You will be presented with this pop-up box:


Select the recordset you created, select the All Records radio button and click OK. What do you see? The same table we created in the first example. Dreamweaver MX generates the table, adds the dynamic fields from the recordset, and finally adds a repeat region all in 1 step!

Go To Detail Page

This behavior usually consists of two pages: the Master and the Detail page. This concept is based on the one-to-many table relationship, that is, two tables where the primary key of a record is stored as a foreign key in a second table that contains additional information associated with that record - we can retrieve information from both tables as long as we have the key present (if you need a refresher on this, please review Chapter 6).

You can also use this server behavior to retrieve different numbers columns from the same table on different pages. For example, you may like to display minimal information about records on your master page, but have more info present when you drill down on detail pages - you pass the primary key onto a detail page, open the same recordset, but retrieve more columns than those retrieved on the master page.

In our webprodmx_data database, the categories and books tables have a one-to-many relationship - the primary key of the categories table is stored as a foreign key in the books table. The schema is set up like this so that each book is associated with a particular category. In a real-world web application we would display the categories on a master page and pass the primary key ID of a selected record to a detail page that displays the books associated with that ID.

Master Page

We already have a working master page that displays the categories from our database named categories.asp. We need to adjust it so that we make each category link to a detail page passing the Unique ID of the record (which will be the primary key: category_id) as a URL parameter. (If you need a refresher on URL Parameters, please review Chapter 5.)

Let's take a new copy of categories.asp and call it categories2.asp. Now, highlight the category dynamic text within the HTML table and select Server Behaviors, then +, then Go To Detail Page, as seen here:


The Go To Detail Page dialog box looks like this:

Fill in the fields as shown. We have not created the Detail page yet, but write books.asp in that field (we will create this page next). By default, the URL parameters passed (Pass URL Parameter) should be the category_id. You can change the name of the URL Parameter, but it's easier for us if we name the URL Parameter after the database column name. You could also manually change the value of the Pass URL Parameter field and the Column selector to pass a different column as the URL Parameter, but you will usually pass the primary key of the table since this is the unique key. Passing other columns is usually done in addition to passing the unique column. Make sure Recordset and Column are set to rsCategories and category_id respectively.

Leave the checkboxes besides Pass Existing Parameters unchecked, since we have no existing URL parameters already appended to the URL of this page or form parameters that we want to pass to the books.asp; we have no existing URL or form parameters. If there were we could choose to pass them along with the category_id URL parameter we are passing here. Hit OK and the category dynamic text will turn into a hyperlink.

Before we create the detail page (books.asp) let's have a look at categories2.asp in a browser so we can see what has happened. If you hover your mouse over the category hyperlinks, you will see that each one has its own URL - see the status bar at the bottom of the browser window overleaf:


The number passed as the category_id value will be relative to the category, and is in fact the Access autonumber (primary key) for that record. Now we just need to create books.asp! However, before we do that, let's look at an alternative way to generate our dynamic links.

An Alternative Way To Generate a Master Page

Instead of using the Go To Detail Page behavior here, you could manually generate the action of passing a URL Parameter to a detail page, like so. Let's take another copy of categories.asp and call it categories3.asp.

Now, highlight the category dynamic text as before, but this time go down to the Properties window and select the little yellow folder to the right of the Link field. You should be presented with the following dialog box:


Type in books.asp for the filename and click the Parameters button to the bottom right - you should now see something like the following:

Under Name, fill in the name of our URL Parameter, category_id; for the value field, we want to pull the appropriate values out of our database - click the lightning bolt icon to the right of the field, to bring up the following:

From here, expand the rsCategories recordset, select the category_id column and hit OK. Hit OK again to close the Parameters dialog box, now that we have filled in our Value column, and hit OK a third time to close our File Select dialog box.

Now if you look at the Link field in the Properties window, you should see that it has been filled in (with something like books.asp?category_id=<%=(rsCategories.Fields.Item
("category
_id").Value)%>). You should also notice that our hyperlinks have been created in our page, the same as when we used the Go To Detail Page.


You can pass URL Parameters with either method. The Go To Detail Page behavior is nice because it saves time but it has a shortcoming - you cannot pass more than one URL Parameter when using the behavior - for example, we might want to pass the category name as a URL Parameter along with the category_id. When you do it manually you have the option of adding multiple Parameters.

Now let's create our books.asp detail page!

George Petrov

George PetrovGeorge 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

See All Postings From George Petrov >>

Comments

Hello to everybody

April 28, 2004 by privat privat
Hi to all and thank you for creating such a usfule website about Dreamweaver Mx , i am a new user and i am trying to start to learn how to be aible to creat my own website and also to use a Dreamweaver so i would like one of your people from the fabules site to help me and to get me starting but in a very easy step because i never ever use those tools , so what u saying about it from a scrach i want to start to learn Dreamweaver , but i don't have a ide how to start and wich is the best first program to start and to learn to designe if you can show me the way i will be very happy , because so many time i try to find a site like this who can help you with the steps and follow the dream i was thinking of my e-mail is xhatiik@hotmail.com and also i have registert my other e-mail in this site DJFones@hotmail.com so please help me i will be very happy to start with Dreamweaver MX Thank You agine.

textsing

October 17, 2006 by Umesh Gamit

RE: Hello to everybody

December 19, 2006 by jerome esperanza
sure no problem... email me: jerome_107@yahoo.com

You must me logged in to write a comment.