Oracle Forms are a development tool that can be used to create applications to enter, access, change, or delete data from an Oracle database in an online, form-based environment. Forms has provided many objects for developing an effective application module. Coupled with the concept of user extensibility.
The Oracle Forms Environment
Oracle Forms operates in a graphical user interface (GUI) environment such as Microsoft Windows 3.x. The primary tools used to develop customized forms are the Object Navigator, the Layout Editor, and the object property sheets. In addition to online forms, Oracle Forms are also used to create and maintain application menus and program unit libraries.
The Object Navigator
The Object Navigator presents all the elements that combine to create an Oracle Forms application module. These elements (or objects) may be manipulated using the iconic buttons and menu options. Within the Object Navigator, the application components are presented to the developer in a hierarchical outline format indicating the organization of the form elements.
Triggers are PL/SQL functions that will be executed based on some specific activity or condition in the form. These activities, called events, are the foundation of Oracle Forms' user extensibility feature. While many of the trigger events will perform a particular default function, a trigger can be written to disable, modify, or enhance the default processing capabilities associated with the event. Triggers can be defined at the form, block, record, or individual field level. In addition, a trigger may cause another trigger to "fire" as well as execute another related program unit.
Alerts are used to provide additional information or other messages that require response or acknowledgment from the user. An alert may contain one to three buttons that can be used to define the action the user wants to execute based on the condition.
Libraries are special Oracle Forms modules that can be defined to contain reusable procedures and functions. By attaching program unit libraries to a form, the program code can be maintained in a single file rather than in each individual form module. Libraries help to assure the quality of an application by ensuring that all modules follow the same set of business rules.
A block in a form generally corresponds to an individual entity (table, view, or snapshot) in the database. Additionally, blocks may be created that do not correspond to any table. These blocks, called non-base table blocks, are usually used to hold generic control information, such as query criteria, counters, conditional indicators, and other information that may relate to more than one record or activity.
Items are grouped in the Object Navigator within their respective blocks. An item corresponds to a single data element or field. These items may contain database columns or may be used as containers for other related data.
Relationships are defined according to how the separate blocks in a form relate to each other. Typically in a multiple block form, one block is usually defined as the primary or master table, and the other blocks display detail information associated with the current record in the master block.
A canvas is the virtual structure where the form objects are laid out. For the most part, canvases are defined as either content or stacked canvases. A content canvas is displayed in its entirety within the form window. Whenever a content canvas is first displayed, any other canvases will be hidden in the window. A stacked canvas, on the other hand, will display "on top" of any existing canvases within the form window.
An editor is a window for viewing and maintaining large data fields. These fields are sometimes included for the entry of user comments or other information that would not normally fit in a displayed item.
LOVs (also called lists of values) provide the user with a list of valid entries for a field. A list of values presents data contained within an object called a record group whereby the user will select one value from the list to populate a form item. The list of values may also be used to validate user input to ensure that a valid value is entered.
An object group is a special mechanism for packaging several form objects into a container, which may then be used in other forms with a minimum of programming. Once an object group is created in a form, any of the form objects may be copied into the object group.
Parameters may be defined for a form in order to provide a startup input for the form. Typically, parameters are used to pass values from one form to a newly called form in a multiple-form application. Prior to the Developer/2000 tools, the only way to pass values between forms was through the use of global variables that tended to use up available memory.
Program units are PL/SQL procedures and functions that can be called by the form triggers. A program unit is equivalent to the third generation programming concept of subroutines. A typical candidate for definition of a program unit is a segment of program code that is used by more than one trigger. Program units should also be used to modularize long code segments.
A property class defines the properties of a class of objects. In cases where many form objects have identical properties, a property class benefits the developer by ensuring that the objects are consistent. Additionally, property classes can be used to enforce standards and to accelerate the development time for a form module.
An object's visual attribute defines the color, font, and style characteristics for an item. While each of these values can be set individually for each object, the visual attribute provides a mechanism to define a valid combination of visual characteristics for a form. A high-quality application should not use many different visual attributes within the items.
A window is the frame within which a form appears on the user's screen. Each canvas is assigned to a specific window in the form and several canvases may be assigned to the same window. A single form can contain several windows or it may consist of only one window.
Object Properties Sheets
The characteristics of each element in a form are defined by its various properties. A context-sensitive property sheet exists for each component, based on the type of object that is being defined. The scroll bar at the right side of the property sheet is used to navigate through the property sheet, and the iconic buttons at the top are used to control activities in the sheet.
The Layout Editor
The Layout Editor presents the canvas on which the form objects are laid out. This tool is operated through the use of iconic buttons and menu choices. The buttons along the left side of the Layout Editor window are used to create and manipulate the form layout objects.
Customizing the Forms Environment
Oracle Forms allows the programmer to modify the development environment using the Tool | Options menu choice. The Designer Options dialog box is used to set the behavior of the Oracle Forms Designer.
The five check boxes establish the operating mode for Oracle Forms Designer. If checked, the first box will cause the current module to be saved automatically whenever a form is generated, and the second box will cause the form to be generated (compiled) whenever it is run from the designer.
By default, Oracle Forms displays a hint in the lower-left area of the screen based on the context of the designer. By selecting the next check box, these hints will be suppressed.
The color palette determines the colors that should be used in a form. It is recommended that the Oracle 16-color palette be used, to ensure color-matching capability between form objects. The Color Palette Mode is used to define how color palettes should be handled in Oracle Forms.
Creating New Forms Modules
A form may be created using the File | New | Form menu choice or by using the create-form hot key (Ctrl+Y). The new form will be added to the Object Navigator. Additionally, whenever the Oracle Forms Designer is started, a new empty form is automatically created.
Customizing Forms with Properties
Oracle Forms' intelligent defaulting capabilities can be used to create useful applications. In many cases, however, it is necessary to define specific characteristics for application objects. This can be done by modifying the properties of the form objects using the object property sheets.
Implementing Triggers and Program Units
Oracle Forms applications can be further customized by developing PL/SQL procedures and functions called triggers. These triggers are attached to specific activities in the form called events. Events typically are defined as before (PRE-FORM, PRE-QUERY, PREINSERT), after (POST-FORM, POST-QUERY, POST-INSERT), or during (WHEN-NEW-FORM-INSTANCE, WHEN-BUTTON-PRESSED) common database activities.
Using Record Groups and Lists of Values for Data Validation
A record group is an internal structure that is analogous to a table in memory. Record groups contain columns and rows with data based on a structure defined by a query or column definition. Usage of record groups include parameters, structured arrays, and validation entities.
Using Relationships to Link Separate Blocks in a Form
The key feature of Oracle (or other relational databases) is that the tables are related to each other by key fields.
Mouse Events, Timers, and Other Advanced Widgets
The standard Windows interface uses various graphical controls and other objects to control the operation of application components. Oracle Forms provides access to many of these features through the use of mouse triggers, timers, and VBX controls. Messaging in most Windows software is through an object called an alert box that has been implemented in Oracle Forms.
Working with the Mouse
The mouse pointer is the primary user-input device for navigation and selection in most Windows applications. Triggers have been provided in Oracle Forms to detect and act on various mouse activities.
Working with Menus
Thus far, all of the application modules that have been developed in this chapter have been completely independent of each other. While an application can be developed using iconic buttons and procedures that can be used to pass control from one form to the next, most applications are held together using menu modules. Typically, a main form is executed first and all other forms are called from the original module.
To create a menu module, use the File | New | Menu, menu choice in the Oracle Forms designer. A new menu module will be created in the Object Navigator. Object groups in the menu are attached libraries, menus, object groups, parameters, program units, property classes, and visual attributes. A menu is defined as a list of options that may reference other submenus or perform tasks such as commands or processing Forms functions.
Libraries, Object Classes, and Visual Attributes
One of the major features of object-oriented programming environments is the concept of reusability. By creating reusable objects, standards can be enforced globally and applications can be developed at an unprecedented pace. Users become more comfortable with an application that appears and operates uniformly. Several objects have been included in Oracle Forms to provide this reusability.
Quality Considerations for Oracle Forms
Oracle Forms can handle a vast array of database processing functions. As with any powerful tool, there are many ways to accomplish the same task. It is the job of the developer to create applications that deliver the highest quality return for the lowest overall cost. Quality in an Oracle system can be classified according to several key attributes:
Oracle Forms provides many tools to ensure the quality of an Oracle application. Triggers provide the constructs necessary to ensure the reliability of a form in adhering to business rules as they have been established. Program unit libraries and reference forms with defined object classes and visual attributes can assist the developer in delivering a reliable system that conforms to the standard presentation format that has been established for the organization. These components also make a system easier to modify to reflect changes in rules or newly desired interfaces.