Plan du site  
pixel
pixel

Articles - Étudiants SUPINFO

Building applications visually with Dreamweaver

Par Andy MUBALAMA N'NAKA Publié le 08/01/2017 à 18:44:56 Noter cet article:
(0 votes)
Avis favorable du comité de lecture
Andy Mubalama

Introduction

In Adobe Dreamweaver, you can use Adobe ColdFusion, PHP, or ASP to build pages that let you search, insert, delete, and update database records, display master and detail information, and restrict access to certain users.

ColdFusion?” you may be asking. “Isn’t ColdFusion the old tag-based language from the ‘90s?” Well, yes, ColdFusion dates from the mid ‘90s and it does primarily steer developers towards the use of a tag-based syntax that’s not quite XML but should feel natural to anyone who’s ever written an HTML document. Don’t let the tag-based syntax distract you from the raw power the language provides. ColdFusion has always focused on making complex and difficult tasks easy. The classic example of this is the ease of querying databases. In most languages you need to have several lines of code to establish a connection to a database server (more if you’re using connection pooling), several lines to build your SQL statement, a couple lines to send the request, more to close the connection and then several more lines of code just to output data from the query into an HTML list However, early versions of ColdFusion consolidated most of this tedious process into one tag that wraps the SQL statement you’re running and one tag that iterates over results.

Building master and detail pages

2.1 About master and detail pages

Master and detail pages are sets of pages used to organize and display recordset data. These pages provide a visitor to your site with both an overview and a detailed view. The master page lists all of the records and contains links to detail pages that display additional information about each record.

Figure 1. Master page

Master page

Figure 2. Detail page

Detail page

You can build master and detail pages by inserting a data object to create a master page and detail page in one operation or by using server behaviors to build the master and detail pages in a more customized way. When using server behaviors to build master and detail pages, you first create a master page to list the records and then add links from the list to the detail pages.

2.2 Build a master page

Before you start, ensure that you define a database connection for your site.

1.To create a blank page, select File > New > Blank Page, select a page type, and click Create. This page becomes the master page.

2.Define a recordset.

In the Bindings panel (Windows > Bindings), click the Plus (+) button, select Recordset, and choose options. If you want to write your own SQL statement, click Advanced.

Ensure that the recordset contains all the table columns you need to create your master page. The recordset must also include the table column containing the unique key of each record—that is, the record ID column. In the following example, the Code column contains the unique key of each record.

Figure 3. Recordset columns selected for a master page

Recordset columns selected for a master page

Typically, the recordset on the master page extracts a few columns from a database table while the recordset on the detail page extracts more columns from the same table to provide the extra detail.

3 Insert a dynamic table to display the records. Place the insertion point where you want the dynamic table to appear on the page. Select Insert > Data Objects > Dynamic Data > Dynamic Table, set the options, and click OK

If you don’t want to show record IDs to users, you can delete the column from the dynamic table. Click anywhere on the page to move the focus to the page. Move the cursor near the top of the column in the dynamic table until the column cells are outlined in red, and then click to select the column. Press Delete to delete the column from the table.

2.3 Create links to the detail page

After building the master page and adding the recordset, you create links that open the detail page. You then modify the links to pass the IDs of the records the user selects. The detail page uses this ID to find the requested record in the database and display it

You create links to update pages using the same process. The results page is similar to a master page, and the update page is similar to a detail page

-Open the detail page and pass a record ID (ColdFusion, PHP).

1 In the dynamic table, select the content placeholder for text that will serve as a link.

Links applied to placeholder selected

2 In the Property inspector, click the folder icon beside the Link box.

3 Browse and select the detail page. The detail page appears in the Link box in the Property inspector. In the dynamic table, the selected text appears linked. When the page runs on the server, the link is applied to the text in every table row.

4 On the master page, select the link in the dynamic table.

5 (ColdFusion) In the Link box in the Property inspector, add the following string at the end of the URL:

Colophon

The question mark tells the server that what follows is one or more URL parameters. The word recordID is the name of the URL parameter (you can make up any name you like). Make a note of the name of the URL parameter because you'll use it in the detail page later.

The expression after the equal sign is the value of the parameter. In this case, the value is generated by a ColdFusion expression that returns a record ID from the recordset.

A different ID is generated for each row in the dynamic table. In the ColdFusion expression, replace recordsetName with the name of your recordset, and replace fieldName with the name of the field in your recordset that uniquely identifies each record. In most cases, the field will consist of a record ID number. In the following example, the field consists of unique location codes.

When the page runs, the values of the recordset's CODE field are inserted in the corresponding rows in the dynamic table. For example, if the Canberra, Australia, rental location has the code CBR, the following URL is used in the Canberra row in the dynamic table:

6. (PHP) In the Link field in the Property inspector, add the following string at the end of the URL

The question mark tells the server that what follows is one or more URL parameters. The word recordIDis the name of the URL parameter . Make a note of the name of the URL parameter because you’ll use it in the detail page later.

The expression after the equal sign is the value of the parameter. In this case, the value is generated by a PHP expression that returns a record ID from the recordset. A different ID is generated for each row in the dynamic table. In the PHP expression, replace recordsetName with the name of your recordset, and replace fieldNamewith the name of the field in your recordset that uniquely identifies each record. In most cases, the field will consist of a record ID number. In the following example, the field consists of unique location codes.

When the page runs, the values of the recordset’s CODE field are inserted in the corresponding rows in the dynamic table. For example, if the Canberra, Australia, rental location has the code CBR, the following URL is used in the Canberra row in the dynamic table:

7.Save the page.

2.4 Open the detail page and pass a record ID (ASP)

1 Select the dynamic content to double as a link.

2 In the Server Behaviors panel (Window > Server Behaviors), click the Plus (+) button, and select Go to Detail Page from the pop-up menu.

3 In the Detail Page box, click Browse and locate the page.

4 Specify the value you want to pass to the detail page by selecting a recordset and a column from the Recordset and Column pop-up menus. Typically the value is unique to the record, such as the record’s unique key ID.

5 If desired, pass existing page parameters to the detail page by selecting the URL Parameters or Form Parameters options.

6 Click OK. A special link surrounds the selected text. When the user clicks the link, the Go To Detail Page server behavior passes a URL parameter containing the record ID to the detail page. For example, if the URL parameter is called id and the detail page is called customerdetail.asp, the URL looks something like the following when the user clicks on the link:

http://www.mysite.com/customerdetail.asp?id=43 The first part of the URL,

http://www.mysite.com/customerdetail.asp, opens the detail page. The second part, ?id=43, is the URL parameter. It tells the detail page what record to find and display. The term id is the name of the URL parameter and 43 is its value. In this example, the URL parameter contains the record’s ID number, 43.

2.5 Find and display the requested record on the detail page

In order to display the record requested by the master page, you must define a recordset to hold a single record and bind the recordset columns to the detail page.

1 Switch to the detail page. If you don’t have a detail page yet, create a blank page (File > New).

2 In the Bindings panel (Window > Bindings), click the Plus (+) button and select Recordset (Query) or DataSet (Query) from the pop-up menu. The simple Recordset or DataSet dialog box appears. If the advanced dialog box appears instead, click Simple.

3 Name the recordset, and select a data source and the database table that will provide data to your recordset.

4 In the Columns area, select the table columns to include in the recordset. The recordset can be identical to or different from the recordset on the master page. Usually a detail page recordset has more columns to display more detail. If the recordsets are different, make sure the recordset on the detail page contains at least one column in common with the recordset on the master page. The common column is usually the record ID column, but it can also be the join field of related tables.

To include only some of the table’s columns in the recordset, click Selected and choose the desired columns by Control-clicking (Windows) or Command-clicking (Macintosh) them in the list.

5 Complete the Filter section as to find and display the record specified in the URL parameter passed by the master page:

• From the first pop-up menu in the Filter area, select the column in the recordset containing values that match the value of the URL parameter passed by the master page. For example, if the URL parameter contains a record ID number, select the column containing record ID numbers. In the example discussed in the previous section, the recordset column called CODE contains the values that match the value of the URL parameter passed by the master page.

• From the pop-up menu beside the first menu, select the equal sign (it should already be selected).

• From the third pop-up menu, select URL Parameter. The master page uses a URL parameter to pass information to the detail page.

• In the fourth box, enter the name of the URL parameter passed by the master page.

6 Click OK. The recordset appears in the Bindings panel.

7 Bind the recordset columns to the detail page by selecting the columns in the Bindings panel (Window > Bindings) and dragging them onto the page. After uploading both the master and detail pages to the server, you can open the master page in a browser. After clicking a detail link on the master page, the detail page opens with more information about the selected record.

A propos de SUPINFO | Contacts & adresses | Enseigner à SUPINFO | Presse | Conditions d'utilisation & Copyright | Respect de la vie privée | Investir
Logo de la société Cisco, partenaire pédagogique de SUPINFO, la Grande École de l'informatique, du numérique et du management Logo de la société IBM, partenaire pédagogique de SUPINFO, la Grande École de l'informatique, du numérique et du management Logo de la société Sun-Oracle, partenaire pédagogique de SUPINFO, la Grande École de l'informatique, du numérique et du management Logo de la société Apple, partenaire pédagogique de SUPINFO, la Grande École de l'informatique, du numérique et du management Logo de la société Sybase, partenaire pédagogique de SUPINFO, la Grande École de l'informatique, du numérique et du management Logo de la société Novell, partenaire pédagogique de SUPINFO, la Grande École de l'informatique, du numérique et du management Logo de la société Intel, partenaire pédagogique de SUPINFO, la Grande École de l'informatique, du numérique et du management Logo de la société Accenture, partenaire pédagogique de SUPINFO, la Grande École de l'informatique, du numérique et du management Logo de la société SAP, partenaire pédagogique de SUPINFO, la Grande École de l'informatique, du numérique et du management Logo de la société Prometric, partenaire pédagogique de SUPINFO, la Grande École de l'informatique, du numérique et du management Logo de la société Toeic, partenaire pédagogique de SUPINFO, la Grande École de l'informatique, du numérique et du management Logo du IT Academy Program par Microsoft, partenaire pédagogique de SUPINFO, la Grande École de l'informatique, du numérique et du management

SUPINFO International University
Ecole d'Informatique - IT School
École Supérieure d'Informatique de Paris, leader en France
La Grande Ecole de l'informatique, du numérique et du management
Fondée en 1965, reconnue par l'État. Titre Bac+5 certifié au niveau I.
SUPINFO International University is globally operated by EDUCINVEST Belgium - Avenue Louise, 534 - 1050 Brussels