Transcript CH5_C

Introduction To Form
Builder
Part C
Eyad Alshareef
1
Objectives
Use Sequence to generate value in a form
 Create List Of Value (LOVs)
 Form items

Eyad Alshareef
2
Form Triggers
 PL/SQL procedure that runs in response to a user or
system action
 Clicking a button
 Loading a form
 Exiting a form
 Triggers can be associated with:
 An entire form (form level)
 A block (block level)
 A specific form item (item level)
Eyad Alshareef
3
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
Eyad Alshareef
4
PL/SQL Editor
Eyad Alshareef
5
Syntax Error in PL/SQL Editor
Eyad Alshareef
6
Creating Form Triggers
(continued)

Triggers dialog box
Shows all block events that can have associated
triggers
 Search using wildcards


PL/SQL Editor
Environment for writing, compiling, and editing
PL/SQL programs
 Source code pane
 Status line

Eyad Alshareef
7
Triggers Dialog Box
Eyad Alshareef
8
Using Form Triggers
 Creating a trigger:
 select the form or form item event
 type the trigger code
 Referencing a form item in PL/SQL code:
 :block_name.item_name
 Triggers are compiled before a form is run
Eyad Alshareef
9
Using Sequences in Forms
 Create a block-level WHEN-CREATERECORD trigger
 Trigger PL/SQL code:
SELECT sequence_name.NEXTVAL
INTO :block_name.item_name
FROM DUAL;
Eyad Alshareef
10
LOV
Eyad Alshareef
11
Form Lists of Values (LOVs)
 List of legal values that can be selected for use
in a form field
LOV
command
button
LOV
display
Eyad Alshareef
12
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
Eyad Alshareef
13
LOV Display
Eyad Alshareef
14
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
Eyad Alshareef
15
Creating an LOV Using the LOV
Wizard
1.
Use the LOV Wizard to:



2.
Specify the LOV display records using a
SQL query
Format the LOV display
Attach the LOV to a form text item
Change the LOV and record group name in
the Object Navigator
Eyad Alshareef
16
Opening the LOV Display


Place the insertion point in the text item to
which the LOV is attached
Press CTRL+L, or from Edit menu of the form
choose the option ‘Display List’
Eyad Alshareef
17
LOV Command Button Trigger
 Create a trigger for the button that does
the following:
1.
Places the form insertion point in the text item to
which the LOV is attached:
GO_ITEM(‘IN_VID’);
2.
Executes the LIST_VALUES command:
LIST_VALUES;
Eyad Alshareef
18
Create an LOV


Right-click anywhere in module
REGISTRATION and select LOV wizard
Select record group based on a query
Eyad Alshareef
19
Create an LOV


Type in a query that would retrieve all records from
table course (do not put a semi-column at the end)
Here you will may be asked to log into the DB
Eyad Alshareef
20
Create an LOV

Select all the columns that you want to appear in you
LOV
Eyad Alshareef
21
Create an LOV

Specify the return value for COURSENAME field

Return value is a field where the course name from your LOV
will be inserted
Eyad Alshareef
22
Create an LOV


Specify title and dimensions
Specify the number of rows displayed at once
Eyad Alshareef
23
Create an LOV


Select COURSENAME as assigned value
Complete your LOV
Eyad Alshareef
24
Create an LOV

To test your LOV:
Run the form
 Click on
CourseName field
 Press CTRL+L

Eyad Alshareef
25
Create an LOV control button




Close your form in
the browser
Return to the Form
buikder, Layout editor
Click on the Control
Button item in the
toolbar on the left and
drag it to a desired
location on your
canvas
Name your button
using Property palette
Eyad Alshareef
26
Create an LOV control button



Right click on the button, and open PL/SQL editor
Select Type – TRIGGER, Name –
WHEN_MOUSE_CLICKED
Type in code the code below
Eyad Alshareef
27
Alternate Form Input
Items
Radio buttons
Check boxes
Eyad Alshareef
28
Radio Buttons
 Limits user to one of two or more related,
mutually exclusive choices
Eyad Alshareef
29
Radio Groups
 Related radio buttons
are part of a radio
group
Radio group
Individual related
radio buttons
Eyad Alshareef
30
Creating Radio Buttons

Radio buttons
Represent data fields whose values must be one of
small set of mutually exclusive selections
 Exist within radio group


Select item type in Layout Wizard
Manually create radio buttons
 Use Radio Button tool
 Change properties using Property Palette
 Align edges using Align Objects dialog box

Eyad Alshareef
31
Creating a Radio Group
1.
2.
3.
4.
5.
Create the form using the Data Block and Layout
Wizards
Open the item Property Palette, and change the
Item Type value to Radio Group
Draw and format the radio buttons on the canvas
Modify the radio button properties
Modify the radio group properties
Eyad Alshareef
32
Important Radio Button
Properties
Name: how the
button is
referenced
within the form
Label: description that
appears next to the
button on the canvas
Radio Button Value:
associated data value
in the database
Eyad Alshareef
33
Important Radio Group
Properties
Name: how the
radio group is
referenced
within the form
Initial Value: data value
of the radio button
within the radio group
that is selected when
the form first appears
Eyad Alshareef
34
Check Boxes


Used to represent fields that can have one
of two values
Check box caption is interpreted as TRUE
or FALSE
If checked, caption is true
 If cleared, caption is false

Eyad Alshareef
35
Check Box Example
Eyad Alshareef
36
Creating a Check Box
1.
2.
3.
Create the form using the Data Block and
Layout Wizards
Open the item Property Palette, and change
the Item Type value to Check Box
Modify the item properties
Eyad Alshareef
37
Creating Check Boxes

Check boxes
Represent data values that can have only one of two
opposing values
 Label represents one value
 Value when Checked



Value that will be saved in database if checkbox checked
Value when Unchecked
Eyad Alshareef
38
Important Check Box Properties
Label: description that
appears next to the check
box on the canvas
Value when Checked: data
value of the item when the
box is checked
Value when Unchecked:
data value of the item when
the box is checked
Check Box Mapping of
Other Values: check
box status when form
first opens, or when new
blank record is added
Eyad Alshareef
39
Convert Major into List Item

In the Property palette, change item type to list
item
Eyad Alshareef
40
Converting Major into a list item

Add item values using the property palette
Eyad Alshareef
41