Creating a Single JSP Page Master-Detail Form that Updates the Master Table

This topic describes the steps involved in creating the model, controller, and view layers of a databound Struts application that allows users to:

Overview

When the page flow is complete, running it from the Page Flow Diagram displays the master detail web page, which looks like this:

Master detail form

The following diagram shows a simple view of the steps you need to take in the Model, Controller, and View layers to create this page flow:

Scenario steps in Model, View, and Controller layers

Following is a more detailed discussion of the high-level steps you need to take in the Model, Controller, and View layers to create this page flow:

Model Layer

Controller Layer (Design Time)

View Layer

Controller Layer (Run Time)

Creating the Master Table

This section describes how you create the master table and its associated navigation, search, and update functionality using the Page Flow Diagram and the Visual Editor.

To create the browse data page and associated JSP page:

  1. Open the Struts Page Flow Diagram.
  2. In the Component Palette, click the Data Page element and drag it to the Page Flow Diagram. Name the data page /browseDeptEmpPage .

    This step creates the following entry in the struts-config.xml file:

    
      <form-beans> 
    
        <form-bean name="DataForm" type="oracle.adf.controller.struts.forms.BindingContainerActionForm"/> 
    
      </form-beans> 
    
      <action-mappings> 
    
        <action path="/browseDeptEmpPage" 
    
          className="oracle.adf.controller.struts.actions.DataActionMapping" 
    
          type="oracle.adf.controller.struts.actions.DataForwardAction" name="DataForm" 
    
          parameter="unknown"> 
    
       </action>        

    When you add a data page, JDeveloper uses Oracle ADF subclasses for the action className and type attributes. In addition, it creates a form bean with the name DataForm. The data form bean dynamically makes the attributes for any binding container available to forms in the application web pages. For more information about action mapping using the Oracle ADF action subclasses, see About the Page Flow in Databound Struts Applications.

  3. Double-click /browseDeptEmpPage icon and click OK in the Select or Create Page dialog box to create a JSP page named browseDeptEmpPage.jsp . Leave the Edit this page now? checkbox selected when you do this.

    JDeveloper creates the browseDeptEmpPage.jsp file and opens the page in the Visual Editor.

  4. In the Data Control Palette, select DepartmentsView1. Select Input Form from the Drag and drop as list and drag DepartmentsView1 to the empty JSP page:

    Described in text

    The Data Control Palette displays the business services available for the page. In this step, you are adding a read-only form that uses a view object, DepartmentsView1, to display the data from the Departments table in the HR database. The user navigates through this table to display the employees for each department in the detail table created later.

    When you add the first databound form to the web page, JDeveloper creates two Oracle ADF project files, DataBindings.cpx and browseDeptEmpPageUI.xml, in the View. DataBindings.cpx defines the binding container for the application as a whole. browseDeptEmpPageUI.xml is the model reference, which defines the data controls used by the individual web page.

    At this point, JDeveloper also updates the struts-config.xml file to define the model reference in the associated <action> element by adding a <set-property> element in the action mapping:

    <set-property property="modelReference" value="browseDeptEmpPageUIModel"/>

    For more information about the Oracle ADF project files, see About the Oracle ADF Project Files. For more information about the Data Control Palette, see Inserting UI Components Using the Data Control Palette

  5. In the Data Control Palette, select DepartmentsView1. Select Navigation Buttons from the Drag and drop as list and drag DepartmentsView1 to the existing form. Make sure you put the buttons inside the form.
  6. Add six columns to the navigation button table.

    Place the cursor to the right of the Next button in the navigation button table and choose Design | Table | Insert Rows or Columns from the menu. In the Insert Rows or Columns dialog, choose:

  7. In the Data Control Palette, open the Operations node under DepartmentsView1. Drag the following operations to the first four empty columns you created in the previous step:

    These are operations specific to DepartmentsView1 and operate only on the records in this view object.

  8. In the Data Control Palette, open the top-level Operations node. Drag the following operations to the last two empty columns in the navigation table:

    These are global operations and apply to any changes made in the page. At this point the design view of the page should look like this:

    Master table with buttons

Creating the Detail Table

This section describes how you create the detail table and its associated navigation functionality in the Visual Editor.

  1. In the Data Control Palette, select EmployeesView3 . Select Read-only Dynamic Table from the Drag and drop as list and drag EmployeesView3 to the JSP page below the master table (partial view shown):

    Design view of detail table

  2. In the Data Control Palette, open the Operations node under EmployeesView3. Select Next Set and select Button with Form from the Drag and drop as list. Drag Next Set to the JSP page below the detail table:

    Next set button inside form box

    You need to select Button with Form to include the form, which indicates which Struts action handles the button behavior. The following code segment shows how this looks in the Source tab:

    <form method="POST" action="browseDeptEmpPage.do">
     <input type="hidden" name="<c:out value='${bindings.statetokenid}'/>" value="<c:out &nbsp;   value='${bindings.statetoken}'/>"/>
     <input type="submit" name="event_NextSet" value="NextSet" <c:out value="${bindings.NextSet.enabledString}" />/>
    </form>

  3. Still in the Operations node under EmployeesView3, select Previous Set and select Button from the Drag and drop as list. Drag Previous Set to the form with Next Set.
  4. In the Applications Navigator click the browseDeptEmpPageUIModel.xml node. If this node is not visible, expand the ViewController | Application Sources | view nodes.

    Described in text

    When you select the UI model file node in the Applications Navigator, the Structure Window displays the UI Model view. This view shows the data controls and iterators used in browseDeptEmpPage.jsp as individual nodes.

  5. In the Structure Window select EmployeesView3Iterator.

    Structure Window with model bindings

  6. In the Property Inspector change the range size for the EmployeesView3Iterator from 10 to 3.

    Property Inspector displaying iterator

Running the Application

You are ready to run the data page you created in the Struts Page Flow Diagram.

To run the application:

  1. Return to the Page Flow Diagram by clicking on the struts-config.xml tab above the Visual Editor.
  2. Right-click on the browseDeptEmpPage icon and select Run.

About the Page Flow in Databound Struts Applications
About the Page Flow in Struts Applications
About the Oracle ADF Bindings
About the Oracle ADF Data Binding Properties
About Oracle ADF Data Controls

 

Copyright © 1997, 2004, Oracle. All rights reserved.