Skip Headers

Oracle Reports Building Reports
10g (9.0.4)

Part Number B10602-01
Go To Documentation Library
Home
Go To Table Of Contents
Contents
Go To Index
Index

Go to previous page Go to next page

39
Building a Simple Parameter Form for a JSP-based Web Report

Figure 39-1 JSP Parameter Form

Text description of simplejsp_rpf.gif follows.

Text description of the illustration simplejsp_rpf.gif


Note:

The JSP Parameter Form in this image enables the user to choose from a list of departments, connect to a database, then run a report based on the selected parameters.


Figure 39-2 JSP-based Web report based on a user parameter

Text description of simplejsp_fin.gif follows.

Text description of the illustration simplejsp_fin.gif


Note:

The JSP-based Web report in this image displays a graph and a tabular report based on the department selected in the JSP Parameter Form. To see how this report was built, refer to the Oracle Reports Tutorial.


Oracle Reports enables you to build reports where certain criteria are defined at runtime. To enable your users to define the criteria at runtime, you can use Parameter Forms. The steps in this chapter show you how to build an HTML Parameter Form using JavaServer Pages for a JSP-based Web report. To build a Parameter Form for a paper report, refer to the Reports Builder Online Help. This chapter shows you how to build a very simple Parameter Form. If this Parameter Form does not suit your needs, refer to a more advanced example located in the Getting Started with Oracle Reports Web site on the Oracle Technology Network (http://otn.oracle.com/products/reports/).

For conceptual information about JSPs and Parameter Forms for Web reports, refer to Section 2.2.1, "About JavaServer Pages (JSPs) and servlets" and Section 1.9.4, "About Parameter Forms for Web reports".

Example Scenario

Suppose you have an existing JSP-based Web report that shows a bar graph of employee salaries per department, as well as a tabular report that shows the employee details. Now, your customers want to be able to specify at runtime the employee information for a specific department, so that they don't have to read the data for all departments. The steps in this report will show you how to add a JSP Parameter Form to this Web report.

This example uses the resulting report from the Oracle Reports Tutorial. If you'd like to learn how to build the Web report that we use in this chapter, follow the steps in the tutorial.

Table 39-1 Features demonstrated in this example
Feature Location

Use a text or HTML editor to create a simple HTML Parameter Form.

Section 39.2, "Create a Parameter Form in HTML"

Use the Data Model and Web Source views in Reports Builder to modify the Parameter Form and save as a JSP.

Section 39.3, "Modify the HTML Parameter Form in Reports Builder"

Use the Data Model view to modify the query for the target report to accept user parameters.

Section 39.4, "Set up the target report"

Test the deployment of the JSP Parameter Form and Web report.

Section 39.5, "Deploy the JSP report and Parameter Form"

39.1 Prerequisites for this example

To build the examples in this manual, you must have the example files we've provided, as well as access to the sample schema that is shipped with the Oracle9i database.

39.1.1 Example files

If you haven't already done so, you can download the files you'll need to complete this example from the Oracle Technology network (http://otn.oracle.com/products/reports) and install them on your machine.

To download and install the example files:

  1. Go to the Oracle Technology Network Web site (http://otn.oracle.com/product/reports).

  2. Click Getting Started with Oracle Reports.

  3. Click Index, then browse the list of examples to find the "Building a Simple Parameter Form for a JSP-Based Web Report" example.

  4. Download the file simplejsppf.zip into a temporary directory on your machine (e.g., d:\temp).

  5. Unzip the contents of the file, maintaining the directory structure, into an examples directory on your machine (e.g., d:\orawin90\examples).

    This zip file contains the following files:

    Table 39-2 Files necessary for building a simple JSP Parameter Form
    File Description

    Examples\SimpleJSPPF\source\paramform.html

    An example HTML Parameter Form, which contains an example List of Values, a field, and a button.

    Examples\SimpleJSPPF\results\paramform.jsp

    This JSP-based Web report contains the modifications to the Parameter Form you will make in Reports Builder.

    Examples\SimpleJSPPF\results\emprev_final.jsp

    The source Web report that will become the target report for the Parameter Form.

    Examples\SimpleJSPPF\results\emprev_param.jsp

    The final JSP-based Web report with a JSP Parameter Form.


    Note:

    If you completed the exercises in the Oracle Reports Tutorial, you can also use the emprevb_<your initials>.jsp file you finished at the end of Chapter 6.


39.1.2 Access to the sample schema

If you don't know if you have access to the sample schema provided with the Oracle9i database, contact your database administrator. You should have access to the "Human Resources" portion of the schema to complete this example.

39.2 Create a Parameter Form in HTML

The steps in this section will show you how to build a simple Parameter Form using plain HTML. You will then modify this HTML Parameter Form in Reports Builder so that you can call the Parameter Form from your JSP-based Web report.

If you don't want to create your own HTML file, you can open the sample HTML file we've provided in the Source directory, called paramform.html, then view the source code.

To create a simple Parameter Form in HTML:

  1. In a text editor or HTML editor, create an HTML page that contains a form. The form should contain a list of values, a field, and a button. The code for this form can look something like the following:

    <form name="form1" method="post" action="">
        <select name="p_department" size="1">
          <option value="1">a</option>
        </select>
        <br>
        <input type="text" name="userid" value="hr/hr@db-connect">
    	<br>
        <input type="submit" name="Submit" value="Run Report">
    </form>
    
    


    Note:

    Although you can use the above code, you will need to change the userid value to reflect the connection information for your data source. You can also copy and paste the HTML code from the provided file, called simplejsppf_code.txt in the SimpleJSPPF/scripts directory, then modify it in a text or HTML editor.


  1. Save the HTML file as paramform_<your initials>.html. When you display this HTML file in a Web browser, it should look similar to the following image:

Figure 39-3 Sample HTML Parameter Form

Text description of simplejsp_html.gif follows.

Text description of the illustration simplejsp_html.gif

39.3 Modify the HTML Parameter Form in Reports Builder

In this section, you will learn how to modify an HTML Parameter Form in Reports Builder to populate the list of values (LOV) you created with values from a data source. You will use JSP tags for Oracle Reports to enable the Parameter Form to access elements from a data model.

39.3.1 Create a data model manually for the Parameter Form

The steps in this section will show you how to create a simple data model for the Parameter Form.

To create a data model:

  1. In Reports Builder, open the HTML file you created, paramform_<your initials>.html.

  2. In the Object Navigator, double-click the icon next to the Data Model node to display the Data Model view.

  3. In the Data Model view that displays, click the SQL Query tool in the tool palette, then click in an open area of the Data Model view to display the SQL Query Statement dialog box.

  4. In the SQL Query Statement field, enter the following SELECT statement:

    
    select department_name, department_id
    from departments
    order by department_name
    
    


    Note:

    You you can enter this query in any of the following ways:

    • Copy and paste the code from the provided text file called simplejsppf_code.txt into the SQL Query Statement field.

    • Click Query Builder to build the query without entering any code manually.

    • Type the code in the SQL Query Statement field.

    Also note that if you have not installed the Pictures table into the sample schema, you will not be able to create this query.


  1. Click Connect, then type the connection information for the "Human Resources" portion of the sample schema.

  2. Click OK. Your data model should look like this:

Figure 39-4 Data Model view of the Parameter Form

Text description of simplejsp_dm.gif follows.

Text description of the illustration simplejsp_dm.gif

  1. Save the report as paramform_<your initials>.jsp.

39.3.2 Create a dynamic LOV in the Parameter Form

In this section, you will learn how to modify the Web source to pull data into the existing list of values (LOV) in your Parameter Form. This data will rely on the data model you created in the previous section. We will also examine the code to explain how each element operates.

To modify the LOV in the Parameter Form in Reports Builder:

  1. Click the Web Source button in the toolbar to display the Web Source view.

  2. In the Web Source view, look for the following code:

    <select name="p_department" size="1">
    <option value="1">a</option>
    </select>
    
    


    Note:

    In the above code, the LOV returns a static value. The display name is "a" and the value is "1".



Go to previous page Go to next page
Oracle
Copyright © 2002, 2003 Oracle Corporation.

All Rights Reserved.
Go To Documentation Library
Home
Go To Table Of Contents
Contents
Go To Index
Index