INTRODUCTION TO FORMS BUILDER

advertisement
Introduction To
Forms Builder
Chapter 5
A Guide to Oracle9i
1
Lesson A Objectives
• Learn how Forms Builder displays forms in a Web
browser
• Use a data block form to view, insert, update, and
delete database data
• Create a data block form that displays a single record
at a time
• Become familiar with the Object Navigator, and use
the Object Navigator to change form object names
• Use the Data Block and Layout Wizards to modify
form properties
• Create a tabular-style data block form that displays
multiple records
A Guide to Oracle9i
2
Displaying Forms in a Web Browser
• Forms are displayed in web browser
• Forms appear inside Forms Services window
• Forms Services window displays menus and
toolbars
• Implemented using a Java Applet using
Oracle9iAS Containers for J2EE, or (OC4J)
Instance
• When developing, workstation runs web
server and web browser
A Guide to Oracle9i
3
Forms Builder to Browser
A Guide to Oracle9i
4
Using A Data Block Form —
Definitions
• Block: group of related form items, such as text fields
and option buttons
• Data block: corresponds to a specific database
table, and contains objects, such as text fields or
option buttons, that display values from the table’s
data fields
• Data block form: one or more data blocks
• Text items: display text input fields
A Guide to Oracle9i
5
Forms Services Window
• Form menu contains selections that allow you to
manipulate the form
• Has a toolbar with buttons to insert, view, modify, and
delete records
• At bottom of the window are lines that display
information about form status
• Query button group allows you to query data, has two
modes:
– Normal mode - can view data records, sequentially step
through the records, and change data values
– Enter Query mode - can enter a search expression in one of
the form fields, and then retrieve the associated records
A Guide to Oracle9i
6
Forms Services Window
A Guide to Oracle9i
7
Using a Form to View Table Records
• Retrieve specific table records:
– Click the Enter Query button
– Type a search expression in one or more of the form text
items
– Click the Execute Query button
• Retrieve all of the records in a table
– Place form in Enter Query mode and do not type search
condition
A Guide to Oracle9i
8
Using a Form to Insert,
Update, and Delete Records
• To insert:
– Use blank record that appears when opening a form or as
last line of query results
• To update:
– Retrieve record with a query, modify field and save
• To delete:
– Retrieve record with a query, use Remove Record button to
delete
A Guide to Oracle9i
9
Viewing and Interpreting Form Errors
• Some errors are detected, or trapped, within the form
and form issues the error message
• Other errors are not detected until the form sends the
data values to the database and Oracle DBMS issues
the error message
• To view information on database errors:
– Click Help menu, Display Error
– Dialog box displays error information
A Guide to Oracle9i
10
Viewing Information
About Database Error
A Guide to Oracle9i
11
Closing a Form and Committing
Changes
• To close a form:
– Click Exit button
– Click Action on the form menu and then click Exit
– Close browser window
• If unsaved changes exist, dialog box will prompt to
save changes
A Guide to Oracle9i
12
Creating a Data Block Form
• When creating a form for a table, Forms
Builder automatically creates:
– Labels
– Text entry fields
– Insert, update and delete and select
queries
A Guide to Oracle9i
13
The Object Navigator
A Guide to Oracle9i
14
Creating a New Data Block Form
• Create a new form module
• Create a new data block using:
– Data block wizard
– Manual process
• Using Data Block Wizard:
– Select table name
– Move editable fields from Available Columns list to Database
Items list
• Use Layout Wizard to create form layout
A Guide to Oracle9i
15
Layout Editor
• Use to customize form display
• Can add images and static text to
enhance form appearance
A Guide to Oracle9i
16
Layout Editor
A Guide to Oracle9i
17
Running a Form
• Click Run Form button
• Form is compiled into a .fmx file for execution
• A text file with same name as form and .err
extension holds errors that occur when
running form
A Guide to Oracle9i
18
Form Components
and the Object Navigator
• Use Object Navigator to view information
about form components
• Use buttons to expand and collapse form
items
• Use Ownership View to group logically
associated components together
• Use Visual View to group visually associated
components
• Can rename objects
A Guide to Oracle9i
19
Modifying Forms Using the
Data Block Wizard and Layout
Wizard
• Wizards can be used to modify existing
forms and layouts in reentrant mode
• Start wizard when component is
selected to modify component
A Guide to Oracle9i
20
Creating a Form to
Display Multiple Records
• Use tabular layout to edit multiple table records at the
same time
A Guide to Oracle9i
21
Lesson B Objectives
• Create a data block form that is based on a database
view
• Learn how to modify form properties to improve form
appearance and function
• Create a master-detail form that contains multiple
data blocks
• Format form text items using format masks
A Guide to Oracle9i
22
Creating a Form Based on
a Database View
• Similar to form based on table but read-only
A Guide to Oracle9i
23
Modifying Form Properties
A Guide to Oracle9i
24
Modifying Form Properties
• Use Property Palette of form object to modify
desired properties
– To access: right click object, select Property
Palette from menu
– Intersection mode modifies properties for multiple
objects at the same time
– To open in intersection mode, select multiple
objects before opening Property Palette
A Guide to Oracle9i
25
Property Palette
A Guide to Oracle9i
26
Modifying Form Prompts and Prompt
Properties Using the Layout Editor
• Edit prompts by changing text in layout editor
• Resize frame to realign items and view
changes
• Use layout editor to modify font and point size
of prompts
A Guide to Oracle9i
27
Modifying Text Item Properties
Using the Property Palette
A Guide to Oracle9i
28
Creating a Data Block Form that
Displays Data from Multiple Tables
• Can create data block forms that display data from
multiple database tables which have master-detail
relationships
• Master-detail relationship: one database record has
multiple related records through foreign key
relationships
• Use data block wizard to create master block (for
master table) first
A Guide to Oracle9i
29
Creating a Data Block Form that
Displays Data from Multiple Tables
• Create detail blocks next and specify relationship on
master-detail tab
– Use auto-join to allow Forms Builder to decide on join
condition
– Use manual join to specify join fields
• Code is added to link form blocks together so that
when new master is selected, new detail appears
A Guide to Oracle9i
30
Multiple Master-Detail Blocks
A Guide to Oracle9i
31
Using Format Masks
to Format Character Strings
A Guide to Oracle9i
32
Lesson C Objectives
• Use sequences to automatically generate primary
key values in a form
• Create lists of values (LOVs) to provide lists for
foreign key values
• Become familiar with different form items that you
can use to enter and modify data values
A Guide to Oracle9i
33
Using Sequences to Generate
Primary Key Values
• Form can be set up to automatically retrieve next
sequence number and populate primary key field
• Form triggers respond to user events or system
actions
• To create a trigger, specify:
– Trigger’s object (i.e. specific button)
– Trigger event (i.e. button press)
– Code that executes
• Use PRE-FORM event to perform action when form
loads
• Use Triggers dialog box to create triggers for objects
A Guide to Oracle9i
34
PL/SQL Editor
A Guide to Oracle9i
35
Using PL/SQL to Create Form
Trigger
• Type code to select next sequence value
• Refer to form item (ID text entry field) as
:block_name.item_name
• Compile code before use to check for syntax
errors
• Must connect to database before compiling
code
• PL/SQL editor displays syntax errors
A Guide to Oracle9i
36
Syntax Error in PL/SQL Editor
A Guide to Oracle9i
37
Creating a List of Values (LOV)
• Use a list of values (LOV) to eliminate user errors
• Pop-up list allows user to select value from list of
choices rather than typing
• User can open LOV by:
– Typing Ctrl-L with cursor in LOV text field
– Click Edit then Display List from Forms Services menu
– Clicking command button with attached trigger to open LOV
• LOV allows user to search for values using wildcards
• LOV data values come from a record group
A Guide to Oracle9i
38
LOV Display
A Guide to Oracle9i
39
Creating an LOV
• To create LOV:
– Use LOV Wizard
– Manually create using Object Navigator
• LOV can contain one or more columns
• LOV appearance can be customized using
layout wizard
• Create a button on main form to launch LOV
using button tool, attach form trigger to button
that opens LOV
A Guide to Oracle9i
40
Representing Data Values
Using Other Item Types
• Use radio buttons and checkboxes instead of text
fields for data entry
• Radio buttons represent small list of mutually
exclusive values
• To use radio buttons:
– Create a radio group containing mutually exclusive radio
buttons
– Specify radio buttons rather than text for item type when
creating form layout
– Create individual radio buttons on canvas using radio button
tool
– Specify initial value for radio group using Property Palette
A Guide to Oracle9i
41
Creating Checkboxes
• Use to represent choice of two opposing
values (i.e. On/Off)
• Use label to indicate what checked value
represents
• Configure “Value when Checked” and “Value
when Unchecked” to specify actual database
values
• Can specify a third value that checkbox has
when unmodified (such as NULL)
A Guide to Oracle9i
42
Summary
• Forms Builder is used to provide users with graphical
user interface for manipulating database objects
• Form can represent one or more tables
• Form can be used to view, create, update and delete
table data
• Form can be used to view data based on database
views
• Use wizards to create and modify form information
• Use PL/SQL editor to edit, compile and debug code
• Actions can be associated with form objects and
events via Form Triggers
A Guide to Oracle9i
43
Download