Oracle WebDB Tutorial Guide
Release 2.2

Part Number A77075-01

Library

Product

Contents

Index

Go to previous page Go to next page

3
Building Components

Estimated completion time: 1 hour

This chapter shows you how to use Oracle WebDB to build components. Components are Web pages with content based on data stored in the Oracle database. Some components, such as reports, display data in a graphical format. Others, such as forms, provide interfaces that end users can use to change data. You can create the following components in WebDB:

Icon  Component  Description 

 

Forms 

Provide an interface to one or more database tables, views, or procedures. 

 

Menus 

Display Web pages containing options that end users can click to navigate to WebDB components, URLs, or other menus. 

 

Frame Drivers 

Consist of Web pages divided into two frames. One frame (the driving frame) contains a SQL query that drives the contents of a second frame (the target frame). 

 

Dynamic Pages 

Display dynamic database data based on SQL or PL/SQL which is executed every time the page is requested. 

 

Reports 

Display the results of a SQL query in tabular format. 

 

Charts 

Display the results of a SQL query as a bar chart. Charts are based on at least two table or view columns: one that identifies the bars on the chart and one that calculates the size of the bars on the chart. 

 

Calendars 

Display the results of a SQL query in calendar format. At least one of the table columns in the query must contain values having the DATE datatype. 

 

Hierarchies 

Display data from a self-referencing table or view (at least two columns in the table must share a recursive relationship). Hierarchies can contain up to three levels and display data such as employees in an organization chart, or the hierarchical relationship between menus in a Web site. 

There is a separate component build wizard for each type of component. Each wizard creates PL/SQL stored procedures. When executed, the stored procedures dynamically create the HTML and JavaScript code to display the component.

In this chapter, you'll learn how to build forms, reports, and charts using Oracle WebDB's component build wizards. You'll also learn how to build Lists of Values which you can use in your components and share with other developers.

This chapter includes the following sections:

Section   

"Before You Begin" 

 

"Building a Form Based on a Table" 

 

"Editing a Form" 

 

"Making a Component Available to End Users" 

 

"Building a Report" 

 

"Editing a Report" 

 

"Building a Chart" 

 

"Building a Shared Component" 

 

"What's Next?" 

 

3.1 Before You Begin

3.2 Building a Form Based on a Table

In Section 2.2, "Building a Table" you created a table (TUTORIAL_TABLE) to contain information about a company's employees. End users in the company's Human Resources department need to be able to add new employees to this table. Your next development task is to build a form that the Human Resources staff can use to perform this part of their job.

  1. In the toolbar at the bottom of the page, click.

    The page displayed is divided into three panels. For this exercise you will use the Create a New Form panel.


    You can build the following types of forms:

    • Form based on stored procedures End users can select values to pass to a stored procedure, then execute the procedure. You used a form based on a stored procedure in Section 2.5, "Executing a Procedure".

    • Form based on tables or views End users can query, insert, update, or delete data contained in a table or view. Forms based on tables or views offer more advanced features than simple Query by Example forms.

    • Master-detail form End users can display a master table row and multiple detail rows within a single HTML page. Values in the master row determine which detail rows are displayed for updating, inserting, and deleting.

    • Query by Example (QBE) form End users can query or insert values in a database table or view. A Query by Example form contains fields that correspond to the columns in the database table or view on which the form is built. You used a Query by Example form in Section 2.4, "Querying a Table".

    In this exercise, you will build a form based a table (TUTORIAL_TABLE).

  2. Click Forms on Tables/Views.

  3. Click Create to display the Create Forms Wizard.

  4. In the Schema list, choose your own schema.


    Note:

    Your schema name is the same as your user name. 


    You can build components in the schema that owns the database objects on which the component is to be based, or in a schema that has been granted explicit database object privileges on the objects on which the component is to be based.

  5. In the Form Name field, type TUTORIAL_FORM.

  6. Clickto display the Tables or Views page.


    WARNING:

    Clickif you need to go back to a previous page of the wizard. Do not click your browser's Back button. 


  7. In the Tables/Views list, choose <YOUR_SCHEMA>.TUTORIAL_TABLE, where YOUR_SCHEMA is the name of your own schema.

  8. Click to display the Form Layout Selection page.

  9. Click Structured.

    Clicking Unstructured enables you to supply your own HTML code for the form.

  10. Clickto display the Formatting and Validation page.

  11. You can accept the default values on the remaining pages. Clickto create the form and display the Manage Component page.


    Note:

    is only displayed when you have reached a point in the wizard where you have provided all the information needed to create the component, and can use the default values in the remaining pages. You can change these default values later, if desired. 



    In the Manage Component page, you can choose from the following options:

  12. Click Run. Your form is displayed on a Web page.


    You can now use the form to query, insert, update, or delete data into TUTORIAL_TABLE.


    Note:

    If you use the form to query a table and more than one row matches the query criteria, Next and Previous buttons are displayed at the bottom of the form so that you can view the query results one row at a time. 


  13. Use the following information to fill in the form.

    Field  Value 

    Empno 

    8 

    Ename 

    WARD 

    Job 

    SALESMAN 

    Sal 

    1250 

    Deptno 

    30 

    Click Insert.


3.3 Editing a Form

As you can see, the form you created, while functional, is not particularly sophisticated. However, you can easily edit the form to improve the appearance and add more functionality.

3.3.1 Editing the basic appearance of forms

You can improve the usability of a form by making some changes to the basic appearance. For example, you can add color to make the form more visually appealing, or provide meaningful labels so the end user can easily see what each field in the form is for.

  1. Click your browser's Back button twice to return to the Manage Component page.

  2. Click Edit to display the Edit Form: Formatting and Validation page.

    In this page, you can specify options that control the appearance of the form. You can also choose the columns you want to display as fields in the form and for each field you can specify a selectable List of Values, a default value, a display format, and choose a JavaScript application for validating the field in the form.

    The page is divided into two. The left side of the page shows the columns that will be displayed as fields in the form. You can perform actions on the fields in the form, such as deleting them, changing their order on the form, or editing their options. The right side of the page is where you edit the options for the currently selected form or field.


3.3.1.1 Adding colors

Adding color is one way of improving the basic appearance of a form and improving the overall end user experience.

  1. Currently, FORM is selected in the left side of the page and the right side of the page is displaying the form-level options, so let's edit those.

  2. In the Box Background Color list, choose a color, for example Turquoise.

  3. In the Box Border list, choose Thin Border.

  4. Make sure that Yes is chosen in the Log Activity list. This means that every time an end user uses the form, details about that usage will be recorded in the activity log. You can view reports on the activity log from the Monitor option on the Manage Component page, or the WebDB Monitor menu.

3.3.1.2 Changing field labels

By default, WebDB uses the column name as the label for the field in the form. Let's change the labels in the form to something more descriptive.

  1. In the left frame, click EMPNO to edit the EMPNO field-level options.


  2. In the Display Name field, type Employee Id.

  3. In the left side of the page, click ENAME. Note that the fields in the right side of the page are updated with information for ENAME.

  4. In the Display Name field, type Last Name.

  5. Change the labels of the rest of the columns to something more descriptive.

    You can change the font of labels to something that's easier to read.

  6. For each column:

    1. In the left side of the page, click the column name, for example EMPNO.

    2. In the Font Face list, choose Arial.

    You can also change the color and size of labels.


    Note:

    The label for EMPNO is already colored red because EMPNO is a mandatory column.

    The value of the label Font Size is relative to your browser's default text size. For example, if your browser's default text size is 12 points, changing the size of a label to +2 would increase the size of the label by two. For information about how to change your browser's default text size, refer to your browser documentation. 


  7. Click Finish to save your changes and display the Manage Component page.

    WebDB keeps a copy of previous versions of your components. If you want to go back to an earlier version, simply click the appropriate Version(s) Status link. Once you have finished editing a component and are happy with the final version, you can click Manage and use the Drop option to delete the old versions of the component.

  8. Click Run to view your changes.


3.3.2 Adding supporting text to a form

Good user interface design requires that any important information about a form should be displayed on the form itself. You should also provide help text to give end users additional guidance if they need it.

  1. Click your browser's Back button to return to the Manage Component page.

  2. Click Edit to display the Edit Form: Formatting and Validation page.

  3. Click thetab to display the Text Options page. In this page, you can specify text that you want to appear at the top or bottom of the form. You can also add help text and specify a template.


  4. In the Title field, type Employees.

  5. In the Header Text field, type:

    <H3>Use this form to add, edit or delete employee information.</H3>
    
    


    Note:

    You can use HTML tags, for example <H3> or <FONT>, to control the appearance of the text, if desired. 


  6. In the Footer Text field, type:

    <FONT COLOR="red">Red text indicates that the field is mandatory and you 
    must enter a value.</FONT>
    
    
  7. In the Help Text field, type:

    <H3>To add a new employee:</H3>
    Fill in the fields on the form and click <B>Insert</B>.
    
    

    In this page, you can also specify the overall look and feel of the page on which the form is displayed by choosing a template. WebDB provides some templates to get you started, but you can also create your own with your company logo, color scheme, and text. For more information about templates, see the WebDB online help.

  8. In the Template list, choose a template, for example PUBLIC.TEMPLATE_3.

  9. Click Preview Template to see what the template looks like.

  10. Close the template preview window and click Finish to save your changes and display the Manage Component page.

  11. Click Run to view your changes.


  12. To view the help text you provided, click the question mark (?) at the top right of the form.

  13. Click your browser's Back button to return to the form.

3.3.3 Adding advanced PL/SQL code

You can use PL/SQL to add more functionality to your forms. For example, you might want to display a custom header, or create a temporary table.

  1. Click your browser's Back button to return to the Manage Component page.

  2. Click Edit to display the Edit Form: Formatting and Validation page.

  3. Click thetab to display the Advanced PL/SQL code page. In this page, you can specify PL/SQL code that runs at different points during the execution of the HTML code that creates the form.


  4. In the before displaying the page field, type:

    htp.print(sysdate);
    
    

    This will print today's date at the top of the page on which the form is displayed.

  5. Click Finish to save your changes and display the Manage Component page.

  6. Click Run to view your changes. Today's date is displayed above the form.


3.4 Making a Component Available to End Users

To enable end users to run a component, you need to provide the following:

Members of the Human Resources department need to be granted execute privileges on TUTORIAL_FORM before they can run it.

  1. Take a look at the URL of the page containing TUTORIAL_FORM.

    This is the URL your end users need to run the form.

    • End users can type the URL in the Address or Location field of their browser.

    • You can provide a link to the URL on another page that end users already know how to access.

    • You can add the component to a WebDB site. For information about adding components to WebDB sites, see Chapter 7, "Managing WebDB Site Content".

    The URL consists of:

    webserver.com:port/dad/your_schema.TUTORIAL_FORM.show
    
    

    where:

    webserver.com 

    is the name of the Web server where WebDB is installed. 

    port 

    is the port used to access the Web server where WebDB is installed. If port 80 is used, this may be omitted. 

    dad 

    is the name of the Database Access Descriptor (DAD) used by WebDB to access the database.

    A DAD is a set of values that specify how WebDB connects to the database to fulfill an HTTP request. A DAD is automatically configured when you install WebDB. 

    your_schema.TUTORIAL_FORM 

    is the package that creates the component. 

    show 

    is the procedure that displays the component. 


    Note:

    The combination of the package that creates the component (for example, your_schema.TUTORIAL_FORM) and the procedure that displays the component (for example, show) is referred to as the run link. The run link of a component is displayed on the Manage Component page. 


    When end users attempt to display the page containing the component, they will be prompted for their user name and password. To be able to use the component, the end user must have execute privileges on the component.

  2. Click your browser's Back button to return to the Manage Component page.

  3. Click Privileges.

    The page displayed is divided into two panels. In this exercise you will use the Grant Additional Privileges panel.


  4. Clickto display a list of the users and roles to which you can grant execute privileges.

  5. Click Next to page through the list if necessary and click HR_TUTORIAL (Role).


    Note:

    If HR_TUTORIAL is not listed, ask your DBA to create this role for you using the instructions in Appendix A, "Tutorial Setup Instructions"


    HR_TUTORIAL is displayed in the User / Role field.

  6. Click Grant Execute Privilege.

    HR_TUTORIAL is displayed in the Existing Grants panel.


    Members of the HR_TUTORIAL role are now able to run TUTORIAL_FORM.


    Note:

    If the form was part of a human resources application, you would need to grant the HR_TUTORIAL role execute privileges on all the components in the application. 


    To revoke execute privileges from a user or role, make sure the check box next to the user or role is checked and click Revoke.

3.5 Building a Report

The Human Resources department has also requested a report that they can use to view employee information.

  1. In the toolbar at the bottom of the page, click.

    The page displayed is divided into three panels. For this exercise you will use the Create a New Report panel.


  2. Make sure Report from Query Wizard is selected, and click Create to display the Create Reports Wizard.

    The Create Reports Wizard produces a SQL query based on the information you provide as you step through the pages of the wizard. If you are familiar with SQL you can also create a report by writing the SQL query yourself.

  3. In the Schema list, choose your own schema.

  4. In the Report Name field, type TUTORIAL_REPORT.

  5. Clickto display the Tables and Views page.

  6. Scroll down the Tables/Views list, and choose <YOUR_SCHEMA>.TUTORIAL_TABLE, where YOUR_SCHEMA is the name of your own schema.

  7. You can accept the default values on the remaining pages. Clickto create the report and display the Manage Component page.

  8. Click Run to display your report.


3.6 Editing a Report

You can edit your report in the same way as you edited the form in Section 3.3, "Editing a Form". For example, you can change the report display options, add text, and add PL/SQL code. You can also use the report edit options to produce more sophisticated reports, such as summary reports, break reports, and parameterized reports. The following exercises show you how to create these advanced reports.

3.6.1 Adding summary information to a report

The Human Resources department would like the total salary to be displayed on the report, so they can easily see how much is being spent on salaries.

  1. Click your browser's Back button to return to the Manage Component page.

  2. Click Edit to display the Edit Reports: Table/View Columns page.

  3. Click thetab to display the Columns Formatting page. In this page, you can specify column alignment, a display format, and whether to add a summary of a column's values.


  4. In the row for the TUTORIAL_TABLE.SAL column:

    1. Check Sum.

    2. In the Format mask field, type $999,999.99.

  5. Click Finish to save your changes and display the Manage Component page.

  6. Click Run to view your changes. The report now shows the total salary.


3.6.2 Adding a break to a report

The Human Resources department has requested that the report be grouped by the different departments, to make it easier to view employees by department. You can create a break report to do this.

  1. Click your browser's Back button to return to the Manage Component page.

  2. Click Edit to display the Edit Reports: Table/View Columns page.

  3. Click thetab to display the Display Options page. In this page, you can specify options that control the appearance of the report.


  4. In the First Break Column list, choose TUTORIAL_TABLE.DEPTNO.

    For best results, you should also order the report by the columns you have chosen to break on.

  5. At the bottom of the page, in the first Order by list, choose TUTORIAL_TABLE.DEPTNO.

  6. Click Finish to save your changes and display the Manage Component page.

  7. Click Run to view your changes. The report is now grouped by department. The total salary is shown for each group as well as for the whole report.


3.6.3 Adding parameters to a report

The Human Resources department has submitted another enhancement request for the report. They want to be able to display the report data for a single specified department. You need to create a parameter that they can use to specify the department.

  1. Click your browser's Back button to return to the Manage Component page.

  2. Click Edit to display the Edit Reports: Table/View Columns page.

  3. Click thetab to display the Parameter Entry Form Display Options page. In this page, you can specify parameters that will be used to specify the data displayed in the report.


  4. In the first Column Name list, choose TUTORIAL_TABLE.DEPTNO.

  5. In the Prompt field, type Department.

  6. Click Finish to save your changes and display the Manage Component page.

  7. Click Parameters to display the parameter entry form for the report.

    The parameter entry form prompts the end user for values to use to display the report. The Department parameter you created is the first field on the parameter entry form. Note that end users can also change the break column and order by settings for the report.


  8. In the Department fields, choose = in the list, and type 10 in the field.

  9. Click Run Report. Now, your report only lists employees who work in Department 10.


3.7 Building a Chart

The Human Resources department has also requested a chart that shows the total salary for each department.

  1. Click your browser's Back button twice to return to the Manage Component page.

  2. In the toolbar at the bottom of the page, click.

    The page displayed is divided into three panels. For this exercise you will use the Create a New Chart panel.


  3. Make sure Chart from Query Wizard is selected and click Create to display the Create Charts Wizard.

    The Create Charts Wizard produces a SQL query based on the information you provide as you step through the pages of the wizard. If you are familiar with SQL you can also create a chart by writing the SQL query yourself.

  4. In the Schema list, choose your own schema.

  5. In the Chart Name field, type TUTORIAL_CHART.

  6. Clickto display the Tables or Views page.

  7. In the Tables/Views list, choose <YOUR_SCHEMA>.TUTORIAL_TABLE, where YOUR_SCHEMA is the name of your own schema.

  8. Clickto display the Table/View Columns page.

  9. In the Label list, choose DEPTNO.

    The values of the Label column are displayed along the axis of the chart.

  10. In the Value list, choose SAL.

    The values of the Value column are used to calculate the size of the bars in the chart.


    Note:

    The default for Value is 1. Choosing a value of 1 is useful if you also choose a group function. For example, you can choose the JOB column from TUTORIAL_TABLE as the label, 1 as the value, and COUNT as the group function. This creates a chart that displays the number of employees in each job classification. 


  11. In the Group Function list, choose SUM.

    The group function groups the Value column values by unique Label column values, and performs an operation on each group of values. In this case, the group function sums the salaries of each department.

  12. In the Order By list, choose ORDER BY LABEL.

  13. You can accept the default values on the remaining pages. Clickto create the chart and display the Manage Component page.

  14. Click Run to display your chart.


3.8 Building a Shared Component

A shared component is a component element such as a link, List of Values, or image that can be used by multiple developers when creating forms, reports, and other WebDB components. You can create the following shared components in WebDB:

Icon  Shared Component  Description 

 

Color 

Set the component background color and other component elements such as report headings and chart bars. 

 

Font 

Set the font for text that appears in components, such as in labels and headings. 

 

Image 

Add graphic image files to a component or its background. 

 

JavaScript 

Perform field- or form-level validation of fields in the component. 

 

Link 

Add hypertext links to jump between components. 

 

List of Values (LOV) 

Add selectable parameters to component fields. The List of Values can be displayed in formats such as combo boxes or radio buttons. 

 

User Interface Template 

Set the look and feel of a page on which a component is displayed. 

Because these component elements are shared, they only need to be created once and will look and behave consistently across components. WebDB Developers can create shared components in a schema on which they have Build In privileges. To use a shared component, developers must have Build In privileges in the schema that owns the shared component.

In the following exercises you'll learn how to create Lists of Values and use them in components. In Chapter 4, "Building Applications by Linking Components" you'll learn how to create and use links.

3.8.1 Building a List of Values (LOV)

End users can use Lists of Values (LOV) to select from a list of possible values rather than type values in fields on forms and component parameter entry forms. There are two types of LOV:

The DEPTNO column in TUTORIAL_TABLE can have a value of 10, 20, or 30. Let's create an LOV so that when the Human Resources staff need to enter a department number they can choose from a list.

  1. Click your browser's Back button to return to the Manage Component page.

  2. In the toolbar at the bottom of the page, click.

  3. Click Lists of Values (LOV).

    The page displayed is divided into three panels. For this exercise you will use the Create a List of Values panel.


  4. Click Static, then click Create LOV to display the Create Static List of Values page.


  5. In the Owning Schema list, choose your own schema.

  6. In the Name field, type TUTORIAL_LOV.

  7. Complete the Display Value, Return Value, and Display Order fields using the information in the following table.

  8. Click Add LOV to create the LOV and display the Manage Lists of Values page.

3.8.2 Testing a List of Values

Once you have created an LOV, you can test it to check how it will appear in a component.

  1. Scroll down to the Select a Recently Edited List of Values panel.


    If TUTORIAL_LOV is not listed:

    1. Scroll up to the Find an Existing List of Values panel.


    2. In the LOV Name Contains field, type TUTORIAL_LOV.

    3. Click Find LOV.

  2. Click Combo to test what TUTORIAL_LOV will look like as a combo box.


  3. Click your browser's Back button.

  4. Click Radio to test what the List of Values will look like as a group of radio buttons.


3.8.3 Using a List of Values in a component

In the previous exercise you created an LOV. In this exercise you will use the LOV in the form and report that you created in Section 3.2, "Building a Form Based on a Table" and Section 3.5, "Building a Report".

3.8.3.1 Using a List of Values in a form

Let's add the LOV to the DEPTNO field in TUTORIAL_FORM.

  1. In the toolbar at the bottom of the page, click to display the Component Building page.

    The Component Building page offers another way of finding components. Here you can search across different types of component.


  2. In the Schema list, choose your own schema.

  3. In the Name Contains field, type TUTORIAL.

  4. Click Find.

    WebDB searches for all components containing the text "TUTORIAL" and lists them at the bottom of the Component Building page. You can use the check boxes to restrict the search further by specifying which type of components to search for.

  5. Scroll down the Component Building page and click TUTORIAL_FORM to display the Manage Component page for the form.

  6. Click Edit to display the Edit Form: Formatting and Validation page.

  7. In the left side of the page, click DEPTNO.


  8. In the Display As list, choose ComboBox.

  9. Clicknext to the LOV field to list the available LOVs. You can only use LOVs stored in schemas on which you have Build In privileges.

  10. Click Next to page through the LOVs if necessary and click <YOUR_SCHEMA>.TUTORIAL_LOV, where YOUR_SCHEMA is the name of your own schema.

  11. Click Finish to save your changes and return to the Manage Component page.

  12. Click Run to view your changes. The Department Id field is now a combo box where the end user can select a department by name, rather than having to know which number to type.


3.8.3.2 Using a List of Values in a report parameter entry form

Let's add the LOV to the Department parameter field in the TUTORIAL_REPORT parameter entry form.

  1. Click your browser's Back button to display the Manage Component page.

  2. In the toolbar at the bottom of the page, clickto display the Component Building page.

  3. In the Schema list, choose your own schema.

  4. In the Name Contains field, type TUTORIAL.

  5. This time, let's just search for reports. Uncheck all the check boxes except for Reports and click Find.

  6. Scroll down the Component Building page and click TUTORIAL_REPORT to display the Manage Component page for the report.

  7. Click Edit to display the Edit Reports: Table/View Columns page.

  8. Click thetab to display the Parameter Entry Form Display Options page.


  9. In the row for the Department parameter, clicknext to the LOV field to list the available LOVs.

  10. Click Next to page through the LOVs if necessary and click <YOUR_SCHEMA>.TUTORIAL_LOV, where YOUR_SCHEMA is the name of your own schema.

  11. In the Display LOV As list, choose Combo box.

  12. Click Finish to save your changes and return to the Manage Component page.

  13. Click Parameters to display the parameter entry form for the report.

    The LOV looks the same as the LOV in TUTORIAL_FORM: the same values are listed in the same order. This improves the usability and consistency of an application, because the end user does not have to learn a different interface before being able to use the report. If you did not use a shared component in this situation, the LOV might be ordered differently or use different names for the departments, which could confuse the end user.


  14. In the Department fields, choose = from the first list and choose Sales (30) from the second.

  15. Click Run Report to show employees in the Sales department (Department 30).

  16. Click your browser's Back button twice to return to the Manage Component page.

3.9 What's Next?

In this chapter, you learned how to:

In Chapter 4, "Building Applications by Linking Components" you will create menus and links to build applications from the individual components you have created.


Go to previous page Go to next page
Oracle
Copyright © 1996-2000, Oracle Corporation.

All Rights Reserved.

Library

Product

Contents

Index