Adding a relational record list to a Faces JSP file

To work with dynamic data on your Web page, you need to define the data source. One dynamic data source you can use is a relational record list. With relational record lists, you can display multiple records from relational database tables.

When you define a relational record list on the page, you make its data available to the Web page. Here are a couple of ways to add a relational record list to a Faces JSP page:

Note: A page code file is required if you want to add a relational record or relational record list to a Faces JSP. If you have page code suppression turned on when adding a relational record or relational record list, you are prompted to allow a page code file to be generated.

To add a relational record list to your Web page by using the Data and Services drawer:

  1. Open the Data and Services drawer on the palette.

  2. Drag a relational record list component from the palette to the Faces JSP page where you want the data displayed. The Add Relational Record List wizard opens.

  3. Give the record list a name to use within the page.

  4. If you have already defined a relational record list elsewhere in the project and want to use data from that list, check

    Reuse metadata definition from an existing record or record list and click Browse to select an input file.

  5. To automatically create a data table with fields for the data, check

    Add data controls. Otherwise, the record list will be added to the Page Data view and be available to the page, but controls for this list will not be generated. Later, you can drag the record list from the Page Data view to the page to display it using a data table.

  6. Click Next.

  7. On the Record List Properties page of the wizard, specify the connection name (or click

    New to create a new connection).

    1. If you click

      New, the Profile Browse dialog opens.

    2. Select an available profile and click OK or click

      New to create a new database profile.

    3. If you click

      New, follow the instructions in the New Connection Profile wizard to create a new database profile.

  8. Once the connection is established, select a table and click Next. The Add Relational Record dialog opens.

  9. On the Add Relational Record dialog:

    1. Select the fields to be included in the relational record list.

    2. To further refine the record list, you can click one of the following tasks or advanced tasks:

      • Modify primary key: The Edit primary keys dialog opens and lists the available columns and primary key columns. Use the arrows to make changes to the primary key columns. Note that this only defines the primary key for this record list definition and does not change the primary key on the actual database.

      • Order results: The Orders dialog opens and lists the available columns. Select the columns to order and choose how to organize them (ascending or descending).

      • Filter results: The Filters dialog opens. Click the Add (+) button to open the Conditions dialog. Here you can filter records so that only those that meet a specific condition are displayed.

      • Add another database table through a relationship: The Create Relationship wizard opens and you can create an existing relationship from the current database or create a new relationship.

      • Auto generate key: The Key Generation dialog opens. Check

        Use Auto Key Generation and then choose a table and the two columns you want to use for auto key generation.

      • Set concurrency control: The Concurrency dialog opens. Concurrency control lets you minimize the time during which a data resource is unavailable for use by other transactions. For example, you might have a long-running transaction which could tie up a data resource for a long time and you want to minimize that time. You can also provide column-level concurrency control. This lets you test whether the underlying data source has been updated by another transaction since pulling down the original data. The columns marked for update and their original values are added explicitly through a WHERE clause in the UPDATE statement so that the statement fails if the underlying column values have been changed. As a result, column-level concurrency control is provided. If the underlying columns have not been updated since retrieving the data initially, pending updates are committed and the locks are released. If locks cannot be acquired or if some other transaction has updated the columns since the beginning of the current transaction, the transaction is rolled back.

    3. Click Next.

  10. In the Configure Data Controls panel:

    1. If you previously checked

      Add data controls, select one of the following kinds of data controls to create:

      • Multi-Column Data Table (one table row per data entry)

      • Single Column Data Table (multiple table rows per entry)

      • Unformatted Controls in a Single Column Data Table

    2. Select which columns you want to display, enter a label for the column, and choose the control type for the each column. Control types can include Output Field, Output Formatted Text, Combo Box, Input Field, Input Text Area, and others. Use the up and down arrow keys to change the order of the columns.

    3. Click

      Options to set additional options. The Options dialog opens with the following tabs:

      • Labels - Contains options for the accessibility labels in the record or the data table. You can align the label so that each label is centered or aligned to the right or to the left. You can also choose to append a colon after each label and to capitalize the first letter of each label.

      • Advanced - Enter a depth level next to

        Depth. The depth level sets the number of levels of data that displays in the Page Data view. If you choose a depth of 3, then the Page Data view display a relational record list (or other data source) with three levels of data. For example, if the first level includes Europe, the second level includes Italy, and the third level includes Milan, then any additional levels (such as locations in Milan) do not display. In addition, levels under Milan do not appear in wizards and do not generate any controls. Check

        Use as default depth to change the default depth level for the user. Check

        Only create data controls to create only a data control on the page. If this option is not checked, the data control and other related controls are created. For example, if you are creating an Input Text component and check

        Only create data controls, only that component is created on the page. However, if you do not check this option, an Input Text component is created as well as a Display Errors component, a Label component, and perhaps a

        Submit button. Check

        Include <label> tags in the source code to create <label> tags that will increase the label accessibility.

      • Buttons - This tab displays if you are updating a record. You can choose to add

        Submit and

        Delete buttons to help the user update the record.

  11. Click Finish. The data source is defined for this page and displayed in the Page Data view. If you checked

    Add data controls, controls are generated. Otherwise, drag them from the Page Data view.

Once you have a data table on your page, you can set properties for the data table and any other components that the data table contains. Note that the

Value information for the data table is already filled in.

In addition to adding a relational record list, you can also add a relational record to a Web page.