Transcript CH6_A
Creating Custom
Forms
Part A
Eyad Alshareef
1
Data Block and Custom Forms
Data block form
Based on data blocks that are associated with
specific database tables
Reflect the structure of the database
Custom form
Based on control blocks that process data from
multiple tables
Reflect business processes rather than the database
structure
Eyad Alshareef
2
Introduction to Custom Forms
Custom form
Displays data fields from variety of database tables
Contains programs that support organizational
processes
Use lists of values (LOVs) to retrieve data values
Manipulate data using form triggers
Eyad Alshareef
3
Identifying the Business Processes
and Database Operations
Identify processes that form supports
Identify associated database tables
Describe process
Eyad Alshareef
4
Designing the Interface
Visualize how form will look
Eyad Alshareef
5
Creating a Custom Form
Manually create form canvas in Object
Navigator
Create form items by “painting” items on canvas
Using tools on Layout Editor tool palette
Write code that controls form functions
Eyad Alshareef
6
Creating the Form Canvas
Manually create form canvas in Object
Navigator
Start Forms Builder
Create and rename form canvas
Rename form module and form window
Change Title property of form window
Perform in Visual View in Object Navigator
Eyad Alshareef
7
Creating a Control Block
Control data block
Also called control block
Data block not associated with particular database
table
Create new data block in Object Navigator
Specify data block created manually
Use Ownership View
Eyad Alshareef
8
Creating the Form Items
Create
Boilerplate logo image and text
Form text items
Command button items
Display form in Layout Editor
Draw items on form canvas using tools in tool
palette
Eyad Alshareef
9
Creating the LOVs
LOV
Retrieve data from database table
Use LOV Wizard
Run form
To test LOV
Eyad Alshareef
10
Displaying System Date and
Time Values in Form Text Items
System variable
Variable representing value always available to any
form
Display value in text item automatically
Set text item’s Initial Value property
Eyad Alshareef
11
Forms Builder Date and Time
System Variables
Eyad Alshareef
12
Creating Command Buttons
Create and configure buttons
Create form triggers associated with buttons
Eyad Alshareef
13
Creating and Configuring
Command Buttons
Draw button on canvas using Button tool
Button tool on tool palette
Button group
Buttons should all be same size
Wide enough to accommodate longest button’s label
Draw button with longest label first
Eyad Alshareef
14
Creating the Button Triggers
Select Triggers node under button in Object
Navigator
Click Create button to create trigger
Select trigger event
Specify trigger code
WHEN-BUTTON-PRESSED button event
Trigger code executes when user clicks button
Eyad Alshareef
15
Creating the Button Triggers
(continued)
Reference form items:
:block_name.item_name
Clear form text items in form trigger:
Use CLEAR_FORM built-in procedure
Create program unit to set value of text items to
blank text string
Procedure
Code block that executes commands to change one
or more values
Eyad Alshareef
16
Creating the Button Triggers
(continued)
Function
Code block
Returns single value
Create program unit:
Open Object Navigator
Select Program Units node
Click Create button
Program unit does not use DECLARE keyword
Eyad Alshareef
17
Creating a Custom Form
1.
2.
3.
Create the form
Create the form window and canvas manually
Create a control block
4.
Data block that is not associated with a specific table
Contains form items that you manually draw on the canvas
Create form triggers to process data
Eyad Alshareef
18
Form Triggers
Code that is associated with a form object and
an event
Can contain SQL INSERT, UPDATE,
DELETE, and SELECT commands
Referencing form text item values in triggers:
:block_name.item_name
Eyad Alshareef
19
Practice1
Create a custom form that has:
Employee Name
Employee Salary
Department Name
Create a LOV to retrieve block records
Use triggers to retrieve block records
Create a button that calls a program unit to clear
the block.
Eyad Alshareef
20
Creating a custom form
Create a new form module and name it COURSE
Click on data bloc and then on the plus icon. Select
Build a data block manually
Rename your block into COURSE_BLOCK
Eyad Alshareef
21
Create and modify a canvas
Add a canvas by clicking on Canvas in object navigator
and then on a plus sign
Rename your canvas into HEADER, and open it with
Design Editor
Eyad Alshareef
22
Create and modify a canvas
Change the background color of the canvas using the
Property palette
Add a header “Course Information”
Add a picture (download any picture from the web, save
in in C:\\temp, then go to Edit, Import)
Eyad Alshareef
23
Add text boxes and prompts
Using the toolbox on the left, add Course Name text
box and a corresponding prompt:
Eyad Alshareef
24
Add text boxes and prompts
Using the toolbox, add a stacked canvas on COURSE canvas
Name your canvas COURSE_ITEMS
Add Room and Time text boxes and corresponding prompts to
the COURSE_ITEMS canvas
Eyad Alshareef
25
Add control buttons
Return to the main canvas
Using toolbox on the left, add four control buttons.
Name them New, Find, Save and Clear
Eyad Alshareef
26
Adding PL/SQL code
Create triggers for each of the buttons
Add PL/SQL code to the triggers
Eyad Alshareef
27
Adding PL/SQL code
Eyad Alshareef
28
Adding PL/SQL code
Create triggers for each of the buttons
Add PL/SQL code to the triggers
Eyad Alshareef
29
Adding PL/SQL code
Create triggers for each of the buttons
Add PL/SQL code to the triggers
Eyad Alshareef
30
Adding PL/SQL code
Create triggers for each of the buttons
Add PL/SQL code to the triggers
Eyad Alshareef
31
Form Trigger Properties
Trigger activated
In response to event such as clicking button
Trigger name defines event that activates it
Eyad Alshareef
32
Trigger Categories
Eyad Alshareef
33
Trigger Timing
Specifies when trigger fires
PRE
POST
Fire just before event successfully completes
Fire just after event successfully completes
ON-,WHEN-, and KEY
Fire in response to actions
Eyad Alshareef
34
Trigger Scope
Defines where event must occur in order for
associated trigger to fire
Includes object to which trigger attached
And objects within trigger object
Eyad Alshareef
35
Trigger Execution Hierarchy
Defines which trigger fires
When object within form object contains same
trigger that form object contains
By default trigger in higher-level object overrides
trigger in lower-level object
Can specify custom execution hierarchy
Eyad Alshareef
36
Directing Form External
Navigation
External navigation
Form focus
User causes form focus to change by making
different form item active
Item currently selected on form
Internal navigation
Result of internal form code that responds to
external navigation operations or trigger commands
Eyad Alshareef
37
Setting the Form Tab Order
Set tab order
Place items in correct order under Items node
In Object Navigator window
Eyad Alshareef
38
Directing External Navigation
Using Built-in Subprograms
Built-in subprograms
Called built-ins
Use to direct external form navigation
Cannot use in navigational triggers
Eyad Alshareef
39
Built-in Subprograms to Control
External Navigation
Eyad Alshareef
40
Triggers That Fire at
Form Startup
Triggers Fired
User Action
1
2
PRE-FORM
PRE-BLOCK
User starts form
4
Result on User
Screen Display
3
Form appears,
but with no
data visible
5
WHEN-NEW-FORM-INSTANCE
WHEN-NEW-BLOCK-INSTANCE
WHEN-NEW-RECORD-INSTANCE
WHEN-NEW-ITEM-INSTANCE
Eyad Alshareef
Form is
available for use
41
Triggers That Fire as a Result
Of External Navigation
User Action
User places the
insertion point
in a text item
User clicks
the Next Record
button
Triggers Fired
WHEN-NEW-ITEM-INSTANCE
WHEN-NEW-RECORD-INSTANCE
WHEN-NEW-ITEM-INSTANCE
Eyad Alshareef
Result on User
Screen Display
Insertion point
appears in item
Next record
appears
42
Triggers That Fire When a
Form Closes
User Action
User closes
the Forms
Runtime window
Triggers Fired
POST-BLOCK
POST-FORM
Eyad Alshareef
Result on User
Screen Display
Forms Runtime
window closes
43