This task is the third of four in a demonstration on how to create
a multi-page SDO application. In this task you create and configure the detail
page to work with the master page and the multiple-use SDO. It assumes you
have completed:
- Create a Faces JSP that will be used to access a multiple-use SDO. If
you are working with the DB2® V8.2 SAMPLE database and have completed the previous
tasks, open the createEmployee.jsp.
- In the Data drawer of the palette, drag a Relational Record to the page.
The Add Relational Record wizard opens.
- Enter a name for the record, for example, employee.
- Select the Retrieve an existing record or record list from
scope button and leave the Reuse metadata definition
from an existing record or record list checked.
- Click on the Browse button next to the Input file field, and select the
SDO metadata file created earlier, for example, department.xml:
- For the "Create controls for" options, select Updating an existing
record, then click Next.
- Select the appropriate table node, for example, DEPARTMENT_EMPLOYEE, then
click Finish.
- Verify that the Page Data view shows the relational record for the table
and that a form is generated on the page with the appropriate fields and controls.
For example, using the SAMPLE database you should see the employee (EMPLOYEE)
relational record in teh page Data view and a form on the createEmployee.jsp containing
the Empno, Firstnme, Mininit, and Lastname fields as well as Submit and Delete
command buttons.
- Drag a Link - Command next to the Delete button.
- Click on link label.
- In the Properties view, click h:outputText beneath
h:commandLink and change the Value field to a name appropriate for the action,
for example, Update, then press Enter.
- Select h:commandLink, then click the Quick Edit view icon next to "Click
to code the action this link performs."
- In the left column, click Command.
- Right-click in the script editing area and select .
The Create SubRecord window opens.
- Select the appropriate record or record list, then select the node representing
the table that should be updated, for example, employee (EMPLOYEE).
- Enter a variable name, for example, employee.
- Select Session from the Variable Scope list, then
click OK. If you are working with the DB2 V8.2 SAMPLE
database, verify that the following code is added to the Quick Edit view:
///actionBegin: wdo.createsub.record
DataObject employeeParent = getRootDataObject(getEmployee());
DataObject employee = getRootDataObject(getEmployee()).createDataObject("EMPLOYEE");
employeeParent.getList("DEPARTMENT").add(employee);
getSessionScope().put("employee", employee);
//actionEnd: wdo.createsub.record
- Return to the h:commandLink tab of the Properties view, then click Add
rule.
- Add a navigation rule so that the Link - Command action goes to another
JSP, for example createEmployee.jsp.
- Save the JSP.