 |
|
Oracle Database Tips by Donald Burleson |
Creating
a Master Detail Form with APEX
A Master Detail form
includes several of the features that have been covered so far. The
Master Detail wizard will create two application pages. One page is a
report and the other has a form and a tabular form on the page. There
is the option of separating the second page into two separate pages.
At the developer's request, the wizard will put the form on one page
with a standard report, and another page will have a form to edit a
single detail record for a total of three application pages.
For this example, the DEPT and
EMP tables will be included
with APEX. The DEPT table
is the Master and the EMP
table is the Detail.
The two following sequences can be used for the
population of the primary key columns of the
DEPT and
EMP tables. In the SQL
Workshop
à SQL Commands window, run
the following SQL statements.
create
sequence dept_seq start with 10000
/
create sequence emp_seq start with 10000
/
Next, create the Master Detail form.
1.
Navigate to the application home page for the Easy HTML DB Book
application and click on the Create Page button.
2.
On the next page, choose the Form option and click Next.
3.
On the next page, choose the Master Detail Form page and click Next.
4.
On the Master Table page:
·
Table / View Owner:
EASYHDB.
·
Table / View Name:
DEPT.
·
For the Available Columns, select the icon
to move all columns to the Displayed Columns list, and then click
Next.
5.
On the Detail Table page:
·
Table / View Owner:
EASYHDB.
·
Table / View Name: EMP.
EMP is the only table in the
select list. This is because the Show Only Related Tables item is set
to YES. Therefore, only tables having a foreign key relationship to
the Master (DEPT) table will
be in the select list. If there is no foreign key relationship or to
see all tables, the Show Only Related Tables can be set to NO.
·
For the Available Columns, select the icon
to move all columns to the Displayed Columns list, and then click
Next.
6.
On the Primary Key source page, which will be the primary key for the
Master table:
·
Primary Key Source: Select the Existing sequence option.
·
Sequence: DEPT_SEQ. This is the sequence created
earlier.
·
Click Next.
7.
On the next Primary Key source page, which will be the primary key for
the Detail table:
·
Primary Key Source: Select the Existing sequence option.
·
Sequence: EMP_SEQ. This is the sequence created
earlier.
·
Click Next.
8.
On the Master Options page:
·
Include master row navigation?: YES.
The master row
navigation option will add two buttons, Previous and Next, to the
Master part of the Master Detail page. These buttons are shown in
Figure 8.18. These buttons will scroll through the records in the
Master (DEPT) table one at a
time.
·
Master Row Navigation Order: DNAME.
The Master Row
Navigation Order will provide the sorting for the data in the Master
part of the Master Detail page. If no selection is made here, the
sorting will be determined by the primary key. Choosing a different
sorting order may impact the performance.
·
Include master report: YES.
This option is
what indicates to the wizard you also want the report page. The
report page that will be built by the wizard is shown in Figure 8.17.
If a Report page has already been created, NO can be selected here to
prevent the wizard from creating another one.
·
Click Next.
9.
On the Layout page, select the Edit detail as tabular form on same
page option and click Next.
To get the wizard to create two separate
pages, choose the Edit detail on separate page option. What this will
do is put a standard report in place of the tabular form in Figure
8.18. A separate form page will be built to allow edits on the Detail
(EMP) records.
One reason to create a separate page to edit
the detail records is because performing validation on the data in a
Tabular Form is difficult. Having a separate form to edit an
individual record makes data validation much easier.
10. On
the Page Attributes page, enter the data as shown in Figure 8.16.
This is where the names of the pages and regions the wizard is going
to create are setup. When the entries are completed, click Next.
11. No
tabs and click Next.
12.
Finally, click Create and then, Run Page.
The pages produced from the wizard are shown in
Figures 8.17 and 8.18. From here the developer can go into the pages
and regions and do any customizations as they choose. Also, as
mentioned during the exercise, some developers may also have chosen to
provide their own report to replace the report created by the Master
Detail wizard. In this case, they will go to their custom report and
add the navigation links to navigate to the Master Detail page.
The above book excerpt is from:
Easy HTML-DB
Oracle Application Express
Create
Dynamic Web Pages with OAE
ISBN 0-9761573-1-4
Michael Cunningham & Kent Crotty
http://www.rampant-books.com/book_2005_2_html_db.htm |