Title: Creating Custom Forms
1Creating Custom Forms
2Lesson A Objectives
- Learn about custom forms
- Create a custom form
- Create command buttons that use form triggers to
manipulate data - Use the Forms Debugger to find form logic and
runtime errors - Learn how form triggers work
- Create form navigation triggers
3Custom Forms
- Display the data fields from a variety of
database tables - Contain programs that support organizational
processes - Not associated with one table
- When creating custom forms
- Identify the processes that the form is intended
to support, then identify the associated database
tables. - Helpful to draw interface on paper
4Creating a Custom Form
- Manually create the form canvas in the Object
Navigator - Create the form items by painting the items on
the canvas, using tools on the Layout Editor tool
palette - Write the code that controls the form functions
- Use a control data block
- Not associated with one database table
- Contains manually drawn form items
- Controlled with form triggers
5System Date and Time Variables
6Creating Command Buttons
- Create a command button by drawing the button on
the canvas using the Button tool - Create button triggers manually for custom forms
- Trigger fires on WHEN-BUTTON-PRESSED event
- If multiple buttons execute similar actions (like
clearing a form) create a separate program unit
for this action
7Sample Button Trigger Commands
8Using the Forms Debugger to Find Runtime Errors
- Use the Forms Debugger to find runtime errors
that occur while a form is running - Identify the program line that is causing the
error, and examine the variable values used
within the command that has the error - Investigate the nature of the error by looking up
the error code explanation - Error codes with the FRM- prefix are Forms
Builder error codes - Error codes with the ORA- prefix are generated by
the DBMS - Look up error code on otn.oracle.com
9Using the Forms Debugger
- Click the Run Form Debug button on the Forms
Builder toolbar - Set a breakpoint, which pauses execution on a
specific program command - To debug
- Examine the current values of all program
variables - Step through the program commands to observe the
execution path - Examine variable values to see how the values
change
10Setting a Breakpoint
11Forms Debug Console Windows
12Viewing Text Item Values
13Form Trigger Categories
14Trigger Properties
- Trigger timing
- Specifies when a trigger fires
- Can be just before, during, or after its
triggering event - Before PRE-
- After POST-
- During WHEN-, ON-, KEY-
- Trigger scope
- Defines where an event must occur in order for
trigger to fire - Includes the object to which the trigger is
attached, and contained objects
15Trigger Properties
- Trigger execution hierarchy
- Defines which trigger fires when an object within
a form object contains the same trigger that the
form object contains - Can specify custom execution hierarchy
16Directing Form External Navigation
- Form focus currently selected item has form
focus - External navigation
- Occurs when the user causes the form focus to
change by making a different form item active - Internal navigation
- Occurs as a result of internal form code that
responds to external navigation operations or
trigger commands - Use external navigation to
- Specify initial form focus when form opens
- Specify tab order
17Setting Tab Order in Object Navigator
18Directing External Navigation Using Built-in
Subprograms
19Lesson B Objectives
- Learn about default system messages and how to
suppress them - Create alerts and messages to provide system
feedback - Create applications that avoid user errors
- Learn how to trap common runtime errors
20System Message Severity Levels
21Suppressing Messages
- SYSTEM.MESSAGE_LEVEL
- Variable used to suppress error messages
- Set to 0, 5, 10, 15, 20, 25 to suppress all
messages with severity below this level - Default value is 0
- Set value in PRE-FORM trigger
22Providing System Feedback
- Custom message
- A short text string displayed on the form message
line - Use when the form needs to provide a short,
simple message that does not require an
acknowledgement from the user - To create MESSAGE('message_string')
- Can be up to 200 characters
23Alerts
- Dialog box that can display a longer text message
- Displays one or more buttons that allow the user
to select between alternatives that execute
associated program statements - Use when
- Message is longer than 200 characters
- User acknowledgement is required
- User choice is required
- See Figure 6-22 for example alert
24Displaying an Alert
- In a form trigger
- DECLARE
- alert_button NUMBER
- BEGIN
- alert_button SHOW_ALERT('alert_name')
- END
- Use ELSIF structure to interpret and act on user
response
25Avoiding User Errors
- Forms should help users avoid errors by
- Validating input values
- Programmatically disabling form command buttons
- Disabling navigation for form text items
containing values that users should not change
26Text Item Validation
27Form Validation Triggers
- Item validation triggers
- Perform complex validations
- Associate with WHEN-VALIDATE-ITEM event
- Trigger code tests the current item value to
determine if it satisfies the validation
condition - If input not valid, form displays a message and
raises a built-in exception named
FORM_TRIGGER_FAILURE
28Disabling Form Command Buttons
- Disable command buttons to prevent users from
pressing them before form is in proper state - SET_ITEM_PROPERTY('UPDATE_BUTTON', ENABLED,
PROPERTY_FALSE)
29Disabling Text Item Navigation
- Prevent users from modifying primary key values
- Make text item nonnavigable
- user cannot press the Tab key to place the
insertion point in the text item - To prevent user clicking item
- Create a trigger that moves the insertion point
to another form item whenever the user clicks the
text item using the mouse
30Trapping Common Runtime Errors
- Provide better error messages for common errors
- Create form-level trigger for ON-ERROR event
31Syntax for ON-ERROR Trigger
32Lesson C Objectives
- Convert data blocks to control blocks
- Link data blocks to control blocks
- Create a form that has multiple canvases
- Create tab canvases
- Create stacked canvases
33Converting a Data Block to a Control Block
- Save time by creating a data block and converting
to a control block - To convert data block to control block
- Change the data blocks Database Data Block
property value to No - Change the Required property value of the text
item that represents the data block tables
primary key to No
34Linking a Data Block to a Control Block
- Useful in complex forms with master-detail
relationships - Master is control block, details are data blocks
- To link a control block with a data block
- Create the control block
- Create the data block
- Specify the link between the control block and
the data block - Modify the form triggers to refresh the data
block when the underlying data values change
35Control/Data Block Form Example
36Creating Forms with Multiple Canvases
- Use multiple screens to avoid displaying too much
information - Single-form approach
- Create one form with multiple canvases
- Enables the form to share data among the
different canvases - Impossible for multiple programmers to work
simultaneously on different canvases of the same
application - Multiple-form approach
- Create multiple forms with a different .fmb file
for each application canvas - Works well when multiple programmers collaborate
to create a complex application
37Viewing Canvas and Block Information
38Creating Multiple Canvas/Block Forms
- Specify block and canvas ordering in Object
Navigator - To navigate to another canvas programmatically,
use GO_ITEM to navigate to an item on the canvas - Refer to items in triggers with syntax
block_name.item_name - Use caution to make sure items are placed in
correct blocks
39Creating and Configuring Tab Canvases in Forms
- Multiple-page canvases that allow users to move
between multiple canvas surfaces by selecting
tabs at the top of the canvas. - Use to
- Display a large number of related items in a
modular way - Direct a user through a sequence of steps for
performing a task - Lies on top of a content canvas within the form
window. - Tab page
- An object representing a surface that displays
form items - Has a tab label identifier at the top
40Creating a Tab Canvas
- To create
- Create the form
- Create a new content canvas in the form
- Create a tab canvas on the content canvas
- Configure the tab pages
41Creating a Tab Canvas
42Creating and Configuring Stacked Canvases in Forms
- Lies on top of a content canvas
- Use to hide canvas objects and then make the
objects appear as needed - Create by
- Painting canvas in the desired position on an
existing content canvas - Configure stacked canvas properties
- Create the form items that are to appear
- Write form triggers that contain commands to
display the stacked canvas when it is needed and
to hide the stacked canvas when it is not needed
43Configuring a Stacked Canvas
44Summary
- Control blocks are created manually and do not
represent data from only one table - Control blocks can be created from data blocks to
make coding easier - Forms Debugger is used to find runtime errors in
forms - User errors should be avoided by limiting
opportunities for error - User feedback is presented in message line and
alert boxes - A form may contain more than one canvas canvases
can be organized using tabs or shown and hidden
programmatically