Configuring a Faces master page to use with an SDO

This task is the second of four in a demonstration on how to create a multi-page SDO application. In this task you create a configure the master page to work with multiple-use SDO and the detail page. It assumes you have completed:

  1. From Page Data view, drag a relational record onto a JSP that you want to use as a master page. If you are working with the DB2® V8.2 SAMPLE database and have completed the previous tasks, open the updateDepartment.jsp.
  2. Select Updating an existing Record, then click Finish to generate the form on the master page.
  3. Save the JSP.
  4. Right click on the JSP and select Edit Page Code. By default, a Java™ file is shown containing server code for the JSP. If you are working with the DB2 V8.2 SAMPLE database and have completed the previous task, verify that methods getDepartment()and getDepartmentMediator() are created.
  5. Modify the get<SDO-Name>() method with code that will update the appropriate database table. For example, you could replace the getDepartment() method with the following:
    public DataObject getDepartment() {
    if (department == null) {
    if(!getSessionScope().containsKey("department")){ 
    doDepartmentFetchAction();
    getSessionScope().put("department", department);
    } else 
    department = (DataObject) getSessionScope().get("department"); 
    }
    return department;
    }
  6. Save and close the Java file.
  7. On the master page, for example, updateDepartment.jsp, drag a Link - Command next to the Delete button.
  8. Click on link label.
  9. In the Properties view, click h:outputText beneath h:commandLink and change the Value field to a name appropriate for the action, for example, Add Employee, then press Enter.
  10. Select h:commandLink, then click the Quick Edit view icon next to "Click to code the action this link performs."
  11. In the left column, click Command.
  12. Right-click in the script editing area and select Insert Snippet > Create SubRecord. The Create SubRecord window opens:
    Create SubRecord Screen Capture
  13. Select the appropriate record or record list, then select the node representing the table that should be updated, for example, DEPARTMENT_EMPLOYEE (EMPLOYEE).
  14. Enter a variable name, for example, employee.
  15. 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 employeeListParent = getRootDataObject(getDepartment()).getDataObject("DEPARTMENT[1]");
    DataObject employeeList = getRootDataObject(getDepartment()).createDataObject(" EMPLOYEE");
    employeeListParent.getList("DEPARTMENT_EMPLOYEE").add(employeeList);
    getSessionScope().put("employeeList", employeeList);
    //actionEnd: wdo.createsub.record
  16. Return to the h:commandLink tab of the Properties view, then click Add rule.
  17. Add a navigation rule so that the Link - Command action goes to another JSP, for example createEmployee.jsp.
    Note: For information on creating navigation rules, refer to Using navigation rules with Faces JSP pages
  18. Save the JSP.
To continue creating a multi-page SDO application, follow these steps:

Feedback