9.4 Managing Master Detail Forms

A master detail form reflects a one-to-many relationship between two tables in a database. Typically, a master detail form displays a master row and multiple detail rows within a single HTML form. With this form, users can insert, update, and delete values from two tables or views.

Tip:

To see a working examples of one page and two page master detail forms, install the sample application, Sample Projects and view the Projects page. See "Installing a Packaged Application."

Topics:

9.4.1 About Master Detail Forms

A master detail form reflects a one-to-many relationship between two tables in a database. Typically, a master detail form displays a master row and multiple detail rows. When you create a master detail form using the Create Page or Create Application Wizards, you choose the tables on which to build the master form and the detail form.

Single Page Master Detail

A single page master detail features two editable interactive grids based on two related tables or views. Users select a row in the master grid to update the detail grid. Developers can create a single page master detail with either the Create Application Wizard or the Create Page Wizard.

A single page master detail features two editable interactive grids based on two related tables or views.

Description of GUID-4387D49C-3C96-46A5-B5FD-DF7B54EC239A-default.png follows
Description of the illustration GUID-4387D49C-3C96-46A5-B5FD-DF7B54EC239A-default.png

Users select a row on the master grid to update the detail grid. In this example, when the user selects a department on the master grid to view employees in the detail grid. Developers can create a single page master detail with either the Create Application Wizard or the Create Page Wizard

Description of GUID-A6F40D9F-53EC-4E2D-8C19-6D97DFBE8BBF-default.png follows
Description of the illustration GUID-A6F40D9F-53EC-4E2D-8C19-6D97DFBE8BBF-default.png

Two Page Master Detail

A two page master detail features two pages based on two related tables or views. The first page is a non-editable interactive grid. Users click the Edit icon on the first page edit details on the second page.

In this example, users click the Edit icon to access all employees within a department. The second page includes both a standard form (for the master) and editable interactive grid of employees.

For numeric and date fields, you can also pre-define date and number format masks, or apply those format masks after generating the initial form. Wizard generated master detail forms also automatically create validations for some columns. Validations are created for columns that are set to NOT NULL in the underlying table and columns of type NUMBER, DATE or TIMESTAMP. Note that validations are not created for columns if the column is set to read-only, either based on the user's selection, or defined user interface defaults.

Tip:

You can control the appearance of a specific column by editing column attributes.

9.4.2 Creating a Single Page Master Detail Using the Create Application Wizard

When you create a master detail form using the Create Application Wizard, the wizard creates single page with two editable interactive grids based on two related tables or views. With this page, users can query, insert, update, and delete values from two tables or views which are related.

Tip:

The Create Application Wizard uses general best practices to generate the application and does not include several advanced options included in the Create Page Wizard.

To create a master detail form using the Create Application Wizard:

  1. On the Workspace home page, click the App Builder icon.
  2. Click the Create button.
  3. For the application type, select Desktop.
  4. For Name:
    1. Schema - Each application obtains its privileges by parsing all SQL as a specific database schema. Identify the database schema owner.
    2. Name - Enter the name used to identify the application to developers.
    3. Application - Specify an integer value that identifies the application. The application ID must be unique within your Application Express instance. Application IDs between 3000 to 9000 are reserved for internal use by Oracle Application Express.
    4. Theme - Select a theme. Themes are collections of templates used to define the layout and style of an entire application.
    5. Theme Style - Select a theme style. Theme styles are only available for newer applications such as theme 42 and 51.
    6. Click Next.
  5. Click the Add Page button.

    On Create Application:

    1. Select Page Type - Select Master Detail.
    2. Parent Page - If applicable, select a subordinate page.
    3. Master Table Name - Select the table or view to be used as your master table. This table is used to create a report page and a master form on the master detail page.
    4. Detail Table Name - Select the table or view to be used as your detail table.
      Only tables and views that are associated to your selected Master Table using a foreign key are displayed.
    5. Click Add Page.
      The new page appears at the top of the Create Application page.
    6. Click Next.
  6. For Shared Components, indicate whether to copy shared components from another application. Select Yes or No. If you select Yes, select where to copy them from and which components to import.
  7. For Attributes, configure as appropriate and click Next. To learn more about an attribute, see field-level Help.
  8. Confirm your selections and click Create Application.
  9. To view the new master detail page, click Run Page.
    The rendered page appears.

9.4.3 Creating a Single Page Master Detail Using the Create Page Wizard

Using the Create Page Wizard, you can create either a Single Page Master Detail. A Single Page Master Detail features two editable interactive grids based on two related tables or views.

To create a single page master detail using the Create Page Wizard:

  1. Navigate to the application, or create a new application.
  2. On the Workspace home page, click the App Builder icon.
  3. Select an application.
  4. Click Create Page.
  5. For Create a Page:
    1. User Interface - Select a user interface for the page.
    2. Select a page type - Select Form.
  6. On Create Page, select Single Page Master Detail.
  7. On Page Attributes:
    1. Page Number - Enter the page number of the master page. If you identify a new page number, the wizard creates a new page. If you identify an existing page number, the wizard adds the component to that page.
    2. Page Name - Enter the name of the page.
    3. Page Mode - Enter the name of the page. Options include:
      • Normal - The page is presented as a normal Application Express application page.

      • Modal Dialog - The page is presented as a modal dialog. A modal dialog is an overlay window positioned within the viewport, which remains active and focused until the end user dismisses (closes) it. The underlying page is grayed out and the end user is prevented from interacting with the rest of the page until the dialog is closed.

    4. Breadcrumb - Select whether you want to use a breadcrumb navigation control on your page. If you elect to include breadcrumb navigation, additional attributes appear.
    5. Click Next.
  8. For Navigation Menu, select how you want this page integrated into the Navigation Menu. Depending upon the option you select, additional attributes appear. Click Next.
  9. For Master Source:
    1. Master Region Title - Enter a region title for the master region.
    2. Table/View Owner - Select the owner of the table on which you are building an interactive grid.
    3. Table / View Name - Select the table or view on which the grid will be based.
    4. Primary Key Column - Select the name of the column that uniquely identifies a row in the table.
    5. Select Columns - Select one or more columns to be included in the region. Select all columns to be displayed.
    6. Click Next.
  10. For Detail Source:
    1. Detail Region Title - Enter a region title for the detail region.
    2. Show Only Related Tables - Specify whether to restrict the list of detail tables to only those tables related to the master table.
    3. Table/View Name - Select the table or view on which the grid is based.
    4. Primary Key Column - Select the name of the column that uniquely identifies a row in the table.
    5. Master Detail Foreign Key - Select the foreign key that relates between the master and detail tables.
    6. Select Columns - Select one or more columns to be included in the region. Select all columns to be displayed.
    7. Click Create.
    The Page Designer appears.
  11. To view the new master detail, click Save and Run Page.
    The rendered page appears.

9.4.4 Creating a Two Page Master Detail Using the Create Page Wizard

Use the Create Page Wizard to create either a two page master detail. A two page master detail features two pages based on two related tables or views. The first page is a non-editable interactive grid. Users click the Edit icon on the first page edit details on the second page.

To create a two page master detail using the Create Page Wizard:

  1. Navigate to the application, or create a new application.
  2. On the Workspace home page, click the App Builder icon.
  3. Select an application.
  4. Click Create Page.
  5. For Create a Page:
    1. User Interface - Select a user interface for the page.
    2. Select a page type - Select Form.
  6. On Create Page, select Two Page Master Detail.
  7. On Page Attributes:
    1. Master Page Number - Enter the page number of the master page. The master page will contain a read-only master interactive grid. Enter a new page number or an existing page number.
    2. Master Page Name - Enter the name of the master page.
    3. Detail Page Number - Enter the page number of the detail page. The detail page will contain a form and editable interactive grid..
    4. Detail Page Name - Enter the name of the detail page.
    5. Breadcrumb - Select whether you want to use a breadcrumb navigation control on your page. If you elect to include breadcrumb navigation, additional attributes appear.
    6. Click Next.
  8. For Navigation Menu, select how you want this page integrated into the Navigation Menu. Depending upon the option you select, additional attributes appear. Click Next.
  9. For Master Source:
    1. Table/View Owner - Select the owner of the table on which you are building the interactive grid.
    2. Table/View Name - Select the table or view on which the grid is based.
    3. Primary Key Column - Select the name of the column that uniquely identifies a row in the table.
    4. Form Navigation Order - Select the navigation order column used by the previous and next buttons on the Detail Page which navigates to a different master record.
    5. Select Columns - Select one or more columns to be included in the region. Select all columns to be displayed.
    6. Click Next.
  10. For Detail Source:
    1. Table/View Owner - Select the owner of the table on which you are building the interactive grid.
    2. Table/View Name - Select the table or view on which the grid is based.
    3. Primary Key Column - Select the name of the column that uniquely identifies a row in the table.
    4. Master Detail Foreign Key - Select the foreign key that relates between the master and detail tables.
    5. Select Columns - Select one or more columns to be included in the region. Select all columns to be displayed.
    6. Click Create.
    Page Designer appears.
  11. To view the new master detail, click Save and Run Page.

The rendered pages appear.