Introduction to Oracle Forms Builder

Dr. Awad Khalil

Computer Science & Engineering Department

AUC

Major Forms Builder Tools

Forms Builder has been Oracle’s main form development product for more than 20 years. During this time, Forms Builder applications were used in a mainframe, character-based environment, a client-server environment, and now in the Web environment. Oracle’s Developer uses three different components:

An Integrated Design Environment (IDE) called Forms Builder develops forms. This tool places the desired design components into a binary file with a file extension of .fmb. The binary form file cannot be executed until it is turned into machine code.

A Forms Compiler that creates a compiled (machine language) file based on the form binary file. This file has an extension of .fmx. It is more common, however, to compile the file within the Forms Builder tool.

A runtime engine called Forms Server executes the compiled .fmx files in a Web environment. Forms Server is a middleware product that receives requests from a Web browser and dishes up a Java applet based on the form to the browser

Executing Forms in Web-based Environment

Web applications rely on a Web browser and a Web server.

The Web server controls coordination. When using a form on the Web, the executable file is registered with the Web server.

To execute the Web form, a user requests a URL in his Web browser. The URL points to an application registered within Forms Server. A listner on the Web server catches this URL request and passes it to Forms Server. The Forms Server locates and executes the .fmx file. It changes the .fmx file into a Java applet and sends it to the Web browser.

To execute a form in a Web browser, the client unit must have an applet called JInitiator. When an Oracle form is executed through the Web , the Web server storing the form sends the Jinitiator applet to the client’s Web browser (if it does not already exist on the client). Jinitiator is a generic applet, which is downloaded once to the client. It is actually a plug-in that ensures the Web browser can interact with Forms Server. It is also used to paint the form within the browser, validate data, and communicate with Forms Server. Forms Server reads and executes the .fmx file. Forms Server communicates with the database and with the applet on the Web browser.

Launching Forms Builder’s IDE

One way to launch Forms Builder, you select:

Start < All Programs < Oracle Developer Suite < Forms Developer < Forms Builder

Launching Forms Builder opens the Welcome to the Forms Builder and then the Object Navigator, the heart of Forms builder. Object Navigator is a Forms Builder tool that displays the various form components as well as other form modules, menu modules, and database objects. This tool enables you to select various form objects for modification. It also allows you to add and delete form components. When Forms Builder is launched, the Object Navigator displays one blank module. A module is another name for the form binary file that contains the application components.

Object Navigator

Logging on to the Oracle Database

When starting a Forms Builder session, first connect to the Oracle database. The database furnishes much of the information you need to develop the form. It supplies Forms Builder with the names of tables and columns and each column’s data type, length, and prompt properties. It also supplies constraint information that is used to set required (NOT NULL) properties and range properties.

There are several methods of connecting to Oracle, in fact, you can use Forms Builder for many tasks without connecting to the database. However, Oracle attempts to log you on to the database whenever Forms Builder needs some information from the database. This attempt can occur when you are using a wizard or compiling a PL/SQL script. When Forms Builder attempts to log you on to the database, it displays a modal dialog box requesting you to enter the following :

Normally, a developer connects to Oracle when starting a Forms Builder session by performing one of the following functions:

From the menu, click File/Connect

Press the Control and J keys. These are IDE hot keys that perform the same function as the File/Connect menu selection.

For your first practice session, launch Forms Builder and connect to the Oracle database by performing these steps:

Locate and select the Forms Builder option on the Start menu.

If the Welcome to the Forms Builder dialog box opens, click the Cancel button.

When you are in the main work area, log on to Oracle by selecting File/Connect menu option.

Enter your Oracle ID information into the Connect dialog box. This generally consists of the Oracle ID, password, and connect string. If you are using an Oracle database that is installed on your PC, the default ID is scott/tiger and a connect string is needed.

Click the Connect button. The dialog box disappears when you are connected.

Forms Builder IDE Tools

Forms Builder has tools that are used to build forms:

Object Navigator: Locates and navigates to any form component. Double-clicking any object in the Object Navigator causes Forms Builder to display the selected object within the appropriate Forms Builder tool. The Object Navigator can also be used to create, delete, copy, and rename form components. (can be launched by clicking F3).

Property Pallete: Used to define special characteristics of the form’s components. Each component has a different set of properties. Examples of component properties include case restriction, length of value, data type, or prompt value. Properties can be used to substantially control a form’s behavior. Double-clicking an object in the Object Navigator generally opens the Property Pallette tool. (can be launched by clicking F4).

Layout Editor: It paints the form. This tool allows you to move and arrange form objects, set font and fill colors, add components to the form, and add a boilerplate. Doule-clicking ang graphic component in the Object Navigator causes the layout Editor to display a canvas that contains the graphic objects. (can be launched by clicking F2).

 PL/SQL Editor: Used to write the PL/SQL scripts needed by a form. These PL/SQL scripts are placed in triggers associated to a form object or into program units that are embedded in the triggers. A trigger is a PL/SQL code block whose execution is based on a form event, such as double-clicking a form object, navigating to another text item, or pressing an F key. Program units are PL/SQL scripts that are named and stored within a form or in a database. (can be launched by clicking F11).

Properties Palette

Layout Editor

PL/SQL Editor

Creating a Simple Form Using the Data Block and Layout Wizards

Forms are composed of a variety of objects, but each form must have the following three components:

Data Block: this is the form object that contains data elements. The data block is usually closely related to a database table or view. The data block elements receive database values for display, update, or deletion. Data blocks also receive information that has been input for insertion into the database. Data blocks generate dynamic SQL statements (INSERT, UPDATE, and DELETE) that interact with the database.

Canvas: This is the form object that is shown to the user and is displayed in the Layout Editor. All displayed form components must be placed on a canvas to be displayed. Canvases also contain graphic symbols and a boilerplate.

Window: This is the form object that displays the canvas.

These three components can be created manually using the Object Navigator, but it is much more common to use the Data Block and Layout Wizards, especially for newly created forms.

Creating a Form Module

The first task in creating a form is to create a form module. A form module is a binary file that holds the form components. To determine whether a form module has been brought into the Forms Builder session, you must display the Object Navigator. The Object Navigator displays a hierarchical list of parent and child objects. For example, if we look at the Object Navigator shown before, we ca recognize six objects (or parents) on the left side of the Object Navigator: FORMS, MENUS, PL/SQL LIBRARIES, OBJECT LIBRARIES, BUILT-IN PACKAGES, and DATABASE OBJECTS. Under the FORMS object is a node called MODULE1. this is one instance of the FORMS parent object and is a child node. The Object Navigator allows you to have multiple child nodes. Under the MODULE1 node are additional child nodes: TRIGGERS, ALERTS, ATTACHED LIBRARIES, DATA BLOCKS, and so on. Theses are form objects or components that make up a form. The Object Navigator lays out all available objects in this hierarchy of parent and child objects or nodes.

If a form module exists, you see the name of the form as a FORMS object child node. Under the FORMS node is a child node called MODULE1. This is a new created form module ready for modification. The form module is named MODULE1 by default. Forms Builder generates a new default name whenever a new module is created, and the default name changes to the name of the file when the module is saved.

The Object Navigator can contain multiple form modules. Selecting any form module child node causes that form module to be the current module. Existing form modules can be brought into Forms Builder in two ways:

Using the File/New menu option to create a new form module.

Using the File/Open menu option to retrieve an existing module from the file system.

Using the Data Block Wizard to Create a Data Block

Now that you have seen a form module, you are ready to create the first of the three mandatory objects listed previously: the data block. Use the Data Block Wizard to create new data blocks and modify them. The wizard can be launched in three ways:

Use the Tools/Data Block Wizard menu option.

Click the DATA BLOCKS node in the Object Navigator. Click the Create tool on the left toolbar. The icon for this tool has a green plus sign. This option causes a dialog box to open. You are prompted to either launch the Data Block Wizard or to build it manually.

Use the Welcome to the Forms Builder dialog box by clicking the Use the Data Block Wizard radio button.

As stated earlier, the Data Block Wizard can be used to create a new data block and modify an existing block. If you selected an existing block in the Object Navigator, the Data Block Wizard displays information about this data block. If you want to create a new data block, be sure that an existing data block is not selected. Forms generally contain several data blocks. After creating the first data block, it is very easy to attempt to create a second data block while the original is still selected. If you launch the Data Block Wizard with a data block selected, the wizard modifies the currently selected data block and eliminates the settings that you have established. This is a common error for novice developers. They launch the Data Block Wizard while a data block is selected. When they are finished, the components of the first data block are gone, leaving them modified. If you want to create a new data block, be sure that a non-data block form module object is selected before launching the Data Block Wizard. This causes Forms Builder to create a new data block

The Data Block Wizard consists of a series of modal dialog boxes or pages that allow you to set a number of data block properties or specifications. The Welcome to the Data Block Wizard page appears first. There is a Display this page next time check box in the lower-left corner of the page. Clicking this box to clear to clear the check mark prevents this dialog box from appearing. Each of the wizard pages has Back and Next buttons that allow you to move between the wizard pages. Clicking the Next button on the Data Block Wizard page opens the first important wizard page.

Setting the Block’s Data Source Type

The next Data Block Wizard page, the Type page is used to enter the data block’s data source type. This dialog box has two radio buttons: Table or View and Stored Procedure. Selecting the Table or View option sets up the data block to use an Oracle table or view. A table is a database object that stores records. Views are stored SELECT statements that create and return result set or derived table. Stored procedures are named PL/SQL scripts that reside in the database. They can be used in conjunction with a Ref Cursor and used as a data source. The Table or View option is the more common option

The next wizard page is used to set the data source. This page does not appear unless you are logged on to Oracle. If you were not previously logged on, you are prompted to log on to Oracle before the page appears. Note the following features of this page:

Table or view: Text item used to document the name of the data source table or view.

Browse: Button that launches the Tables dialog box used to search and identify tables and views for the Table or View text item.

Refresh: Button that populates the Available Columns list box. Use this button only if a database change occurs while the wizard is open.

Enforce data integrity: Check box that causes Forms Builder to add the target table’s database constraints to the data block item properties.

Available Columns: List box displaying columns available for the data block.

Database Items: List box displaying columns that will be placed in the data block.

Move buttons: Four buttons that appear between the list boxes. They are used to add and remove columns from the list boxes. Single-arrow tools move only the selected columns; double-arrow tools move the entire contents of the list box. Double-clicking any list box column moves it to another list box. The Delete key can also be used to remove columns from the Database Items list box.

It is not necessary to place all available columns into the data block; however, any table column that contain a NOT NULL constraint must be selected to perform DML operations without errors.

Clicking any list box object on the Tables dialog box and clicking the OK button populates text items on the Data Block Wizard Table page. The selected table name will appear in the wizard Table or View text item. In addition, the wizard page, Available Columns list box, will be populated with the selected table’s columns. The Tables dialog box is a common Oracle tool. Oracle is a distributed database, and the target data can be located on a variety of Oracle installations. The dialog box aids you in searching the various installations and in locating the appropriate data source. Note the following dialog box characteristics:

Display: A series of check boxes used to filter the database objects.

Current user: Allows objects owned by you, the developer, to appear in the list.

Other users: Allows objects on which you have been granted privileges to appear.

Tables: Allows database tables to appear.

Views: Allows views to appear.

Synonyms: Allows synonym names to appear. A synonym is another name for a database object.

Database object list box: Displays the results of a database search based on the values in the Display check boxes. The list box has two components: TABLE and OWNER. TABLE contains the name of the object. OWNER lists the Oracle ID that owns the object. Blank values indicate the current user owns the object.