Adding relational record data to a Faces JSP page

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. With a relational record as the data source, users can create, read, update, or delete records on Web pages.

To add a relational record 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 from the palette to the Faces JSP page. The Add Relational Record wizard opens.

    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.

  3. Specify a name to refer to the record within the page.

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

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

  5. To add data controls to the page automatically, check

    Add input/output controls to display the record on the Web page. If you do not check this, the relational record is added to the page code file and to the Page Data view, but data components are not added to the Faces JSP file. To add controls later, simply drag a record to the page. (Note that an alternate way to add a relational record to your page is to use the Page Data view instead of the Data and Services drawer. You first create the relational record through the Page Data view and then drag the record onto the Web page.)

  6. In the "Create controls for" section, select one of the following controls when you drag the record to the page:

    • Displaying an existing record (read-only): The default component is often an Output Text component but depends on the property's run time type. The data record is initialized to contain data from an existing record.

    • Updating an existing record: The default components are input field components. The data record is initialized to contain data from an existing record.

    • Creating a new record: The default components are input field components. The data record is initialized as an empty record. The record displays as a new row in the database.

  7. Click Next. The Record Properties page opens.

  8. 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.

  9. In the Record List Properties page, select the table you want to use from the data source.

  10. Click Next. The Add Relational Record dialog opens.

  11. On the Add Relational Record dialog:

    1. Select the columns (fields) to be included in the relational record.

    2. To further refine the record, 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.

      • 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. Choose a collision column [more explanation needed here]

    3. Click Next. The Configure Data Controls panel opens

  12. In the Configure Data Controls page:

    1. Select the fields you want to display, change the labels displayed next to the fields, and select the control type to use. Depending on whether you chose to display, update, or create a record, the 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 fields.

    2. Click

      Options if you want to create additional options. The Options dialog opens.

    3. On the Labels tab of the Options dialog, 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.

    4. On the Advanced tab, you can 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. 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.

    5. If you chose to update a record, a Buttons tab also displays on the Options dialog. On the Buttons tab, you can choose to include a

      Submit button (to submit any updates) and a

      Delete button (to delete the record).

    6. If you chose to create a record, a Buttons tab displays on the Options dialog. On the Buttons tab, you can choose to include a

      Submit button (to submit the newly created record).

  13. Click Finish. An HTML table opens, containing rows and other components, based on what you selected. For example, if you chose to update an existing record, an input text component displays and might also include

    Submit and

    Delete buttons to perform update record and delete record actions.

Note that the

Value information for the new UI components is already filled in on their Properties views.

When you create a data record, a default filter is set up to determine which record to display. The filter looks for a record where the primary key column matches the value in a parameter (whose name matches the primary key column name). This makes it easy to set up an update or details page. When you link to this page, you should pass this the value of the primary key column using this parameter. Otherwise, the Web page will display only the values of the first record it reads. You can change the filter by configuring the data record.

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