Professional Documents
Culture Documents
2012
FOR
WOMEN
2012
Table of Contents
How to Start Oracle Form Builder ...........................................................................................4
How does Forms Builder translate the form designer specification into a Java Applet ?........... 7
Exploring the Form Builder .....................................................................................................8
What is an Object Navigator?...................................................................................................... 8
Definitions ................................................................................................................................. 10
Types of views ........................................................................................................................... 11
How to view a Form in a Run mode? ........................................................................................ 12
How to view information on database errors? ......................................................................... 13
Modifying FORM Properties ...................................................................................................... 14
Intersection mode ................................................................................................................. 16
Layout editor after changing the properties ......................................................................... 17
Ensuring a Consistent Appearance Across Form Modules ...................................................... 20
Why it is important to maintain a consistent look and feel? .................................................... 20
Two ways to standardize the appearance of multiple forms in an application: ....................... 20
Template Forms ................................................................................................................... 20
Steps to create the template form ............................................................................................ 20
Visual Attribute Groups........................................................................................................ 36
Steps to create visual attribute group for form text items ....................................................... 36
Creating a Form Based on a Template Form .......................................................................... 40
Steps to create a new form using the template ........................................................................ 40
Applying The Visual Attribute Group to The Form Text Items ................................................ 53
Steps to apply the visual attribute group .................................................................................. 53
Referencing Application Components ................................................................................... 58
Using the Path Specification Approach ..................................................................................... 58
Global Path Variable .............................................................................................................. 58
Opening and Closing Forms in an Integrated Database Application ........................................ 59
Steps to create a Home Page form using the template ............................................................ 59
Opening forms in an Integrated Database Application ............................................................. 65
CALL_FORM ........................................................................................................................... 65
OPEN_FORM .......................................................................................................................... 66
NEW_FORM ........................................................................................................................... 67
Page 2
2012
Page 3
2012
Page 4
2012
Page 5
2012
Page 6
2012
How does Forms Builder translate the form designer specification into a
Java Applet ?
It uses a Web server process called an Oracle9iAS Containers for J2EE, or (OC4J)
Instance.
When developing, workstation runs web server and web browser in its main
memory.
Form Builder development environment compiles the form design file ( .fmb) to a
file (.fmx) and send the complied .fmx file to the OC4J Instance, which inturn
translates the compiled .fmx file into a Java applet and then downloads the Java
Applet to your web browser.
Page 7
2012
Click File, Open, select CUSTOMERDEMO (an example of a previously created & saved form)
Page 8
2012
Page 9
2012
Definitions
Block :
o A block is a structure that contains a group of objects such as text fields
or command buttons or option buttons
Data Block :
o A data block is a block that is associated with a database table. When you
create a data block using wizard, the system automatically generates the
text items and labels for data fields in that table and provides the code
for inserting, modifying, deleting and viewing data records.
Data block form: one or more data blocks
Text items: most common block items which display text data values in text
fields
Window :
o Rectangular area on a computer screen that has a title bar at the top.
o Windows have horizontal and vertical scroll bars.
o Windows can be resized, maximized and minimized.
Canvas :
o A canvas is the area in a window in which you place graphical user
interface ( GUI) objects, such as buttons and text fields.
Items : are form objects that a user sees and interacts with on the canvas.
Trigger : A Trigger is a PL/SQL program that starts in response to an event. An
event is a response to a user or system action, such as clicking a button or
loading a form, that occurs in a window application.
Relation : A relation is a form object that Forms builder creates for a form that
displays two data blocks whose underlying database tables have a foreign key
relationship.
Page 10
2012
Types of views
1. Ownership view :
a. Presents the form as the top level object and then list all form object nodes
on the next level. In this view, data blocks, canvases and windows all appear
as objects directly below the form module.
b. The object Navigator does not show hierarchical relationships among
windows, canvases and blocks.
c. It shows which items are in a specific block.
d. It is useful for quickly accessing specific objects without having to open all of
the higher level objects.
2. Visual view :
a. Presents how form objects contain other objects i.e. a form contains
window, a window contains canvases, and a canvas contains data block.
b. Visual view does not show data block.
c. It is useful for viewing and understanding form object relationship.
Page 11
2012
Page 12
2012
Page 13
2012
Page 14
2012
Page 15
2012
Intersection mode
We can use property palette in intersection mode to modify one or more properties of a group
of objects so that all objects in the group have the same value or values.
Indicates is in
intersection mode
Page 16
2012
Page 17
2012
Page 18
2012
Page 19
2012
Different form developers usually work on one single database, therefore they
may be not consistent
To make the forms appear as a polished and integrated application
To speed up the form development process as you dont need to do it from
scratch
To reduce user training time and frustration
Template Forms
It is generic form that includes standard form objects that appear in every form
in an application, (e.g. graphics, command buttons, and program units)
Ensures a uniform overall appearance for application forms
You store the template form in a location that is accessible to all developers.
In this manual, well create a template form for the Northwoods University database.
Oracle
Northwoods
University
Logo
Return
Page 20
2012
2. In the Object Navigator, select the MAIN node, and then click the Collapse All
button to collapse the MAIN form objects.
3. Select the top level Forms node, and then click the CREATE button to create a
new form. Change the form module name to NORTHWOODS_TEMPLATE.
Page 21
2012
4. To create the new canvas, select the Canvases node and then click the Create
button. Change the canvas name to TEMPLATE_CANVAS.
5. To configure the template window, open the Windows node, and change the
form window name to TEMPLATE_WINDOW. Select the TEMPLATE_WINDOW
node, right-click, and then click PROPERTY PALETTE. Change the Title property
value to Northwoods University, and then close the Property Palette.
Page 22
2012
Page 23
2012
Page 24
2012
Page 25
2012
9. To create the boilerplate Rectangle, select the rectangle tool on the tool palette,
and draw a rectangle that defines the area that contains the logo and return
button. The rectangle should start at the top-left corner of the canvas, and
should extend the entire length of the canvas. The rectangles bottom edge
should be even with the bottom edge of the canvas.
Page 26
2012
10. Select the rectangle if necessary, select the Fill Color tool on the tool palette,
and change the rectangle fill color to a lighter shade of gray than the canvas
background color. The filled rectangle should appear slightly lighter than the rest
of the canvas.
Page 27
2012
11. Make sure that the rectangle is still selected, select the Line Color tool on the
tool palette, and then click No Line.
Page 28
2012
12. To import the Northwoods University logo, click Edit on the menu bar, point to
Import, and then click Image. Click Browse, navigate to
NorthwoodsProject_DONE folder, select NWlogo.jpg, click Open, and then click
Ok. The logo appears on the canvas. Resize and reposition the logo.
Page 29
2012
Page 30
2012
13. To create the return button, select the Button tool on the tool palette, and draw
the button. Double-click the button to open its Property Palette, change the
button properties as follows, and then close the Property Palette:
Name
RETURN_BUTTON
Label
Return
Width
90
Height
16
Page 31
2012
Page 32
2012
14. To create the button trigger, select the button, right-click, point to
SmartTriggers, and then click WHEN-BUTTON-PRESSED. Type the following
command, compile the trigger, debug it if necessary, and then close the PL/SQL
Editor.
EXIT_FORM;
Page 33
2012
Page 34
2012
15. Click Window on the menu bar, and then click Object Navigator to open the
Object Navigator. Note that when you create the Return button, Forms Builder
automatically created a new control block that contains the button. Change the
new block name to TEMPLATE_BLOCK, and then save the form.
Page 35
2012
A form object that defines object properties (e.g. text item colors, font sizes, and
font styles)
Ensures a standard appearance & properties for block items
You assign the visual attribute group after you create it, to Visual Attribute
Group property of form windows, canvases, and items.
2. Select the new visual attribute group, right-click, and then click Property Palette.
Change the Name value to TEXT_ITEM_VISUAL_ATTRIBUTES.
Page 36
2012
3. Make sure that the Visual Attribute Type property value is Common, which
means that the specified properties apply to all attributes in the object; while
Prompt apply only to object prompts, and Title apply only to object titles.
Page 37
2012
4. To specify that the text appears in a dark blue color, select the Foreground Color
property, click the More button
, and then select a dark blue square.
5. To specify that the text appears on a white background, select the Background
Color property, click the More button, and type (or select) white in the property.
6. Select the Font Name property, click the More button, select Arial, and then
click OK. Select the Font Size property, delete the current value, and then type 8.
Page 38
2012
7. Close the Property Palette, save the form, and then close the form in the Forms
Builder.
Page 39
2012
Page 40
2012
Page 41
2012
3. To create the new data block, select the Data Blocks node, click the Create
button, make sure the Use the Data Block Wizard option button is selected, and
then click OK. When the Data Block Wizard Welcome page appears, click Next.
Page 42
2012
4. When the Type page appears, make sure the Table or View option button is
selected, and then click Next. On the Source page, click Browse, select the
LOCATION database table, and click OK. Click the Move all items to target
button
to select all of the table fields for the data block, leave the Enforce
data integrity check box cleared, and then click Next.
Page 43
2012
Page 44
2012
5. When the Master-Detail page appears, click Next because you do not want to
create a master-detail relationship. Accept LOCATION for the data block name,
and click Next. When the Finish page appears, make sure that the Create the
data block, then call the Layout Wizard option button is selected, and then click
Finish.
Page 45
2012
Page 46
2012
6. When the Layout Wizard Welcome page appears, click Next. Accept the default
values on the Canvas page, and then click Next. (Recall that you are basing the
new form on the template form, and the template forms canvas name is
TEMPLATE_CANVAS.)
Page 47
2012
Page 48
2012
8. On the Style page, make sure that the Form option button is selected, and then
click Next. On the Raw page, type Location for the frame title, leave the Records
Displayed value as 1, click Next, and then click Finish.
Page 49
2012
9. In the Layout Editor, the new data block objects are not visible because they
appear below the existing form template objects. Scroll to the bottom of the
window, select the Location frame, and drag it to the top of the canvas. Resize
the frame, and format the text item labels, so your form looks like the figure
below
Page 50
2012
Page 51
2012
Page 52
2012
Page 53
2012
2. Click Tools on the menu bar, and then click Property Palette to open the
intersection Property Palette for the text item object group.
3. Scroll down to the Visual Attributes property node, select the Visual Attribute
Group property, open the list, and select TEXT_ITEM_VISUAL_ATTRIBUTES.
Page 54
2012
4. Close the Property Palette, and save the form. Note that the form text items now
appear as a dark blue text on a white background, in an 8-point Arial Regular
font, as specified in the custom visual attribute group.
5. Run the form, click Enter Query button, and then click the Execute Query
button. Step through the table records to view the records, and then close the
browser window.
Page 55
2012
Page 56
2012
Page 57
2012
Steps to use the path specification approach: refer to Step #2 in How to create a button
with a CALL_FORM procedure
Uses: for development team that has standardized procedures for saving all of the
project files to a specific location on a file server
Disadvantage: make it difficult to move the application to a different storage location
because you must change the path specifications in all commands that reference the
form or report files.
Solution: using Global Path Variable
Global Path Variable
A variable that references a text string specifying a complete path to the drive and
folder where you store all the application files
Advantage: enables you to place the path information in a single location. So that
whenever you move the application files to a new location, you only have to change the
specification in the global path variable, instead of changing it in many different
locations.
Syntax: :GLOBAL.variable_name := variable value
To use it: :GLOBAL.variable_name
Example: :GLOBAL.project_path := 'C:\Documents and
Settings\gmazroa\My Documents\NorthWoodsProject_DONE\';
CALL_FORM(:GLOBAL.PROJECT_PATH || 'EXIT_PAGE');
Steps to use the global path variable: refer to How to create a Log-In Page form part.
Page 58
2012
Page 59
2012
Page 60
2012
4. To edit the new form, right-click on HOME_PAGE, and then click on Layout
Editor.
5. In the Layout Editor, click on the Text button on the tool palette, and then draw
it in the middle of the form. To enter a welcome text, type Welcome to
Northwoods University Database.
Page 61
2012
6. To change the format of the welcome message, change the Font to Arial, the
Font Size to 16, make it Bold, and then move it if necessary.
Page 62
2012
Page 63
2012
Page 64
2012
Forms Builder provides a number of built-in procedures that enable you to open one
form from another. The form that calls the second form is the parent form, and the form
that is called is the child form.
Procedure Name
CALL_FORM
OPEN_FORM
NEW_FORM
Description
Opens a child form and immediately switches the application focus to the
child form.
Has options for hiding the parent form, displaying the menu from the
parent form, and passing a parameter list from the parent form.
Opens a child form, with the option of not immediately changing the
application focus to the child form.
Has an option for creating a new database session for the child form or
using the parent forms database session.
Opens a child form and exit the parent form.
CALL_FORM
This procedure opens a child form and immediately switches the application focus to
the child form.
Uses: You can use it when the user clicks a switchboard button or selects a menu item,
and expect to see the child form immediately.
Syntax: CALL_FORM(form_specification, display, switch_menu,
query_mode, parameter_list_id);
Parameter
Description
Form_specification Specifies the child form. Always enclosed in single quotation marks.
Type the child form name if it is located in the default form folder, or
specify the full path and file name, including the drive letter, to the child
forms .fmx file, or you can use the global path variable as following:
:GLOBAL.project_path || form_name.fmx
Display
Specifies whether the parent form is hidden by the child form (HIDE)
default value, or not hidden (NO_HIDE) which is used if you want the two
forms to appear side by side on the screen
Switch_menu
Specifies whether the child form displays the same pull-down menus as its
parent form (NO_REPLACE) default value, or displays different menus
(DO_REPLACE)
Query_mode
Specifies whether the child form runs in normal mode, in which the user
can insert, update, or delete values (NO_QUERY_ONLY)default value, or
in query mode, in which the user can only view data (QUERY_ONLY)
Parameter_list_id Specifies the identifier for an optional parameter list that the parent form
can use to pass data values to the child form.
Page 65
2012
All of the parameters are optional except for form_specification. If you decide to specify a
value for any of the optional parameters, you must specify values for all of the
preceding optional parameter in the list, without including the values for the
subsequent optional parameters if youre willing to accept the default value.
OPEN_FORM
This procedure opens a child form and gives the developer the option of not
immediately changing the application focus to the child form.
Uses: Many developers prefer this procedure because it allows the user to multitask
between parent and child forms in the application.
Syntax: OPEN_FORM(form specification, active_mode,
session_mode, parameter_list_id);
Parameter
Description
Form_specification Same as in CALL_FORM
Active_mode
Specifies whether the application focus switches to the child form
(ACTIVATE) default value, or is retained by the parent form
(NO_ACTIVATE)
Session_mode
Specifies whether the child form uses the same database session as the
parent form (NO_SESSION) default value, or whether the child form
starts a new database session (SESSION).
In the first case, the DBMS commits all uncommitted values in both forms
when a COMMIT command executes. Therefore, the benefit of the second
case is that whenever a COMMIT command is issued, transactions are
committed only in the form in which the commit command executes,
allowing the developer to control how the form commit transactions.
Parameter_list_id Same as in CALL_FORM
All of the parameters are optional except for form_specification. If you decide to specify a
value for any of the optional parameters, you must specify values for all of the
preceding optional parameter in the list, without including the values for the
subsequent optional parameters if youre willing to accept the default value.
Page 66
2012
NEW_FORM
This procedure opens a child form, and immediately exits the parent form.
Uses: use it to allow users to open application forms without going through the main
form switchboard or menus. The advantage: it prevents the user from opening multiple
forms at once, which consumes system memory. But because users should access all
application forms from the main form, it is not recommended to this procedure.
Syntax: NEW_FORM(form specification, rollback_mode,
query_mode, parameter_list_id);
Parameter
Description
Form_specification Same as in CALL_FORM
Rollback_mode
Specifies whether the DBMS automatically commits records in the parent
form and doesnt roll back any uncommitted transactions (NO_ROLLBACK),
rolls back all uncommitted transactions/records to the last save point
(TO_SAVEPOINT), or rolls back all uncommitted transactions/records and
restore the database to its state at the beginning of the database session
(FULL_ROLLBACK).
Query_mode
Same as in CALL_FORM
Parameter_list_id Same as in CALL_FORM
Page 67
2012
To create a button with a CALL_FORM procedure (you can try the other two
procedures):
1. To create a button trigger that calls the form LOCATION, select the Button tool
on the tool palette, and draw the button as shown below. Double-click the
button to open its Property Palette, change the button properties as following,
and then close the Property Palette:
Name
GO_LOCATION_BUTTON
Label
Location
Width
90
Height
16
Page 68
2012
Page 69
2012
3. Save the form, and then Run the form. When the HOME_PAGE form appears,
click Location button. The Location form (LOCATION.fmx) opens.
Page 70
2012
Procedure Name
CLOSE_FORM
EXIT_FORM
Description
Closes the specified form, which might not be the current form
Closes the current form, and provides options for committing or rolling back
the uncommitted data
Page 71
2012
CLOSE_FORM
This procedure closes a specific form, which might not be the form the user is currently
viewing.
Uses: it allows developers to control the open forms in an application
Syntax: CLOSE_FORM(form_specification);
Parameter
Description
Form_specification The form_ID (created by the Form Builder for every open form) or the
name of the form module as specified in the Object Navigator
EXIT_FORM
Rollback_mode
Description
Specifies how the DBMS handles umcommited form data.
(ASK_COMMIT) default value causes the form to ask the user to save
uncommitted changes, (DO_COMMIT) automatically commits unsaved
data, (NO_COMMIT) automatically discards uncommitted changes.
Specifies if the DBMS automatically commits or rolls back uncommitted
records in the parent form.
Same as in NEW_FORM
Page 72
2012
Page 73
2012
3. Change the Data Block name to LOGIN _BLOCK, Canvas name to LOGIN
_CANVAS, and Window name to LOGIN _WINDOW
Page 74
2012
4. To edit the new form, right-click on LOGIN _PAGE, and then click on Layout
Editor.
5. In the Layout Editor, to create a text item (that will be used by students to enter
their usernames and passwords), select the Text Item tool on the Layout Editor
tool palette, and then draw the text item on the form.
Page 75
2012
6. To configure the text item, right-click on the text item, click on Property Pallet,
then modify the following properties:
Name
S_ID
Data Type
Char
Maximum Length
6
Prompt
Student_ID
Visual Attribute Group (optional)
Page 76
2012
Page 77
2012
8. Repeat the previous steps to create a text item for the password with the
following properties:
Name
S_PIN
Data Type
NUMBER
Maximum Length
4
Prompt
Password
Visual Attribute Group (optional)
Page 78
2012
9. To resize the text items, select all of the items as an object group, right-click, and
then click Property Palette. Scroll down to the Physical property node, then
change the Width property value to 80, and the Height property value to 14.
Close the Property Palette. The text items now all appear as the same size.
Page 79
2012
10. To reposition the text items, select the first five of the text items only as an
object group, click Layout on the menu bar, and then click Align Components.
Select the Align Left option button to specify the horizontal alignment, select the
Stack option button to specify the vertical alignment, and then click OK.
Page 80
2012
Page 81
2012
11. To create a Submit button trigger, select the Button tool on the tool palette, and
draw the button as shown below. Double-click the button to open its Property
Palette, change the button properties as following, and then close the Property
Palette:
Name
SUBMIT_BUTTON
Label
Submit
Width
60
Height
16
Page 82
2012
Page 83
2012
12. In the Layout Editor, select the Submit button if it is not already selected. Then
click the Copy button on the tool bar to copy the button, and click the Paste
button to paste the copied button onto the form. Forms Builder pastes the new
button directly on top of the first button. Select the pasted button, and drag it
below the original Submit button.
Page 84
2012
13. Select both buttons as an object group, click Layout on the menu bar, and then
select Align Components. Select the Align Left option button to align the buttons
horizontally, and select the Distribute option button to evenly space the buttons
vertically, and then click OK. Position the button group on the form.
Page 85
2012
14. Select the second button, open its Property Palette, change its Name property to
CANCEL_BUTTON and its Label property to Cancel, and then close the Property
Palette. Then save the form.
Page 86
2012
After the Student has entered his/her username and password, they need to click
Submit button to log in. The Submit button trigger must check entered values against
the S_ID and the S_PIN columns in the STUDENT table. If these values exist in the
Student table, the student is able to log into the system and check other forms.
Page 87
2012
16. To create the global path variable, add the following command as the first
command in the trigger:
:GLOBAL.project_path := 'C:\Documents and
Settings\gmazroa\My Documents\NorthWoodsProject_DONE\';
Page 88
2012
17. To create the button trigger, select the Submit button, right-click, point to
SmartTriggers, and then click WHEN-BUTTON-PRESSED. Type the following
command, compile the trigger, debug it if necessary, then close the PL/SQL
Editor, and save the form. (this step is similar to step # 14 in how to create a
template form).
DECLARE
CURSOR STUDENT_LOGIN_CURSOR IS
SELECT S_ID, S_PIN
FROM STUDENT
WHERE S_ID = :LOGIN_PAGE_BLOCK.S_ID
AND S_PIN = :LOGIN_PAGE_BLOCK.S_PIN;
STUDENT_RAW STUDENT_LOGIN_CURSOR%ROWTYPE;
ATTEMPT NUMBER :=0;
BEGIN
WHILE ATTEMPT < 4 LOOP
OPEN STUDENT_LOGIN_CURSOR;
FETCH STUDENT_LOGIN_CURSOR INTO STUDENT_RAW;
IF STUDENT_LOGIN_CURSOR%FOUND THEN
MESSAGE('Log in Successfully');
CALL_FORM(:GLOBAL.PROJECT_PATH ||
'HOME_PAGE');
ELSE
MESSAGE('Wrong Username and/or Password');
:LOGIN_PAGE_BLOCK.S_ID := '';
:LOGIN_PAGE_BLOCK.S_PIN := '';
GO_ITEM('LOGIN_PAGE_BLOCK.S_ID');
ATTEMPT := ATTEMPT + 1;
END IF;
END LOOP;
Page 89
2012
CALL_FORM(:GLOBAL.PROJECT_PATH || 'EXIT_PAGE');
END; +comments
An alternative way to create a trigger and open the PL/SQL is from the Object
Navigator. Click on Window on the menu bar, and then click Object Navigator. Open
the SUBMIT_BUTTON node, select the Triggers node, and then click the Create
button to create a new trigger. Scroll down the list of events, and double-click
WHEN-BUTTON-PRESSED. The PL/SQL editor opens.
Page 90
2012
18. To test the trigger, run the form, choose a Username (S_ID) and a Password
(S_PIN) from the Student table to test, then click Submit. If you enter a correct
combination, an alert message appears, click OK, then the HOME_PAGE form
opens.
Page 91
2012
Page 92
2012
19. Test the form to see what happens if you enter a faulty combination and see
how an alert message appears, click OK. After exemption the three trials, the
EXIT_PAGE form opens. (The EXIT_PAGE form is created, compiled, and tested
Page 93
2012
before running the LOGIN_PAGE form to create the EXIT_PAGE.fmx file. This form
was created for illustration purposes only)
Page 94
2012
20. To create the button trigger, select the Cancel button, right-click, point to
SmartTriggers, and then click WHEN-BUTTON-PRESSED. Type the following
command that will clear the text items, compile the trigger, debug it if necessary,
then close the PL/SQL Editor, and save the form.
:LOGIN_PAGE_BLOCK.S_ID := '';
:LOGIN_PAGE_BLOCK.S_PIN := '';
21. To test the trigger, run the form, type any combination for the username and
password, and then click on Cancel. Notice how the fields are cleared now.
Page 95
2012
Page 96
2012
Problem:
When trying a fault combination of username and password three times, it doesnt go to
the EXIT_PAGE form. I tried to solve it but couldnt. I think there is a problem with the
ATTEMPTS variable.
Page 97