Previous | Table of Contents | Next

Page 355

Week 2

Day 13

Developer/2000:
Developing a User
Interface with Oracle
Forms

In the previous lesson, you were introduced to some basic concepts about Developer/2000 and started to work with Oracle Forms. You learned how to build a simple default form based on a single table. In this lesson, you continue with the Forms Designer and build a master-detail form. You also learn how to customize the appearance of a form with the Layout Editor.

NEW TERM
A master-detail form is a form that contains two blocks, the master and detail blocks, which display database records. The master and detail blocks are synchronized; when a record is displayed in the master block, the detail records associated with the master record are displayed in the detail block. For example, a master-detail form might have a master block associated with the

Page 356

Department table and a detail block associated with the Instructor table; when a particular department record is displayed in the Department block, the instructor records associated with that department are displayed in the Instructor block.

NOTE
There are many properties for each object type in Oracle Forms. There simply aren't enough pages in this book to examine the nuances of each of these properties. Instead, I concentrate on the most important object properties.

Building a Master-Detail Form

On Day 12, "Developer/2000: Introduction to Oracle Forms," you used the Forms Designer to build a simple form for viewing and editing student information. Now, you're going to learn how to build a master-detail form. Specifically, you are going to build a form for scheduling a department's classes. The master block will contain the department, and the detail block will contain the classes to be offered by the department. To begin, invoke the Forms Designer by selecting Start | Programs | Developer/2000 for Win95 | Forms Designer. Next, connect to the Oracle database with the username, password, and database alias that you used in the previous lesson. By default, the Forms Designer creates a form named Module1.

Defining the Master Block

To define the master block for your form, follow these steps:

  1. To begin, create the master block by selecting Tools | New Block from the menu. The New Block Options window will appear.
  2. Click the Select button to the right of the Base Table field. Another window will appear in which you can specify which database objects will be displayed for tables to select from (see Figure 13.1).
  3. Click OK. The tables owned by the current user—the username that you specified when you connected to the database—will be displayed.
  4. Scroll down to the Department table, select it, and click OK (see Figure 13.2).
  5. By default, the Forms Designer will name the block with the name of the table. Select the Items tab and click on Select Columns.
    By default, both columns in the table will be selected: Department_ID and Department_Name (see Figure 13.3).

Page 357

Figure 13.1.
Restricting the list of
database objectsto
tables owned by the
current user.

Figure 13.2.
Selecting the Depart-
ment table for the
master block.

Figure 13.3.
Selecting the Depart-
ment table columnsto
include in the master
block.

Page 358

  1. Now, select the Layout tab. In the Style field, select Form from the pop-up list. Check both the Integrity Constraints and the Button Palette, as shown in Figure 13.4. Click OK to complete the creation of the master block.

Figure 13.4.
Setting the layout
options for the master
block.

As you can see in Figure 13.5, the Object Navigator will display the two new blocks: Department and Button Palette (which is the control block created when the Button Palette checkbox is checked). You have now created the master block.

Figure 13.5.
Object Navigator
displays the two new
blocks.

Page 359

NOTE
Notice that you didn't set any properties to indicate that this block is the master block. It is the master block because you are about to create another block that will identify Department as the master block.

Defining the Detail Block

To create the detail block, you'll follow many of the same steps needed to create the master block:

  1. To begin, select Tools | New Block from the menu. Once again, click on Select to the right of the Base Table field to display the list of available tables.
  2. In the Tables window, click OK to display the tables owned by the current user.
  3. Select the Class table and click OK. You should see the New Block Options window, as displayed in Figure 13.6.

Figure 13.6.
New Block Options
window for detail
block.

  1. Select the Items tab and then select Select Columns. Click on the Semester and School Year columns to de-select them. You should see a - to the left of the two columns, indicating that the Forms Designer shouldn't create items for these columns; you won't need the Semester and School Year columns for this example.

Next, select the Layout tab. This time, be sure the Style field is set to Tabular and the Orientation is Vertical. Set Records to 10. Set the Integrity Constraints and Scrollbar checkboxes.

Defining the Relationship

Follow these steps to define the relationship between the master and detail blocks:

  1. To select the master block, select the Master/Detail tab.

Page 360

  1. To the right of the Master Block field, click on Select. A window will appear and, by default, the Department block will be selected (see Figure 13.7). Click OK.
  2. Using the foreign key that exists on the Class table, the Forms Designer will establish the join condition between the master and detail blocks, as shown in Figure 13.8. Click OK to create the detail block, Class.

Figure 13.7.
Choosing the master
block.

Figure 13.8.
Join condition created
by the Forms Designer.

Let's look at the canvas that has been created. Select Tools | Layout Editor from the menu. Figure 13.9 displays what you should see with the Layout Editor. As you can see, there
are a lot of changes you'll need to make to the form before you actually use it. In the next section, you learn how to use the Layout Editor to modify the appearance and properties of the block items.

Previous | Table of Contents | Next

Используются технологии uCoz