eyad alshareef 1 introduction to form builder part c
TRANSCRIPT
2Eyad Alshareef
ObjectivesObjectives
Use Sequence to generate value in a Use Sequence to generate value in a formform
Create List Of Value (LOVs)Create List Of Value (LOVs) Form itemsForm items
3Eyad Alshareef
PL/SQL procedure that runs in response PL/SQL procedure that runs in response to a user or system actionto a user or system action Clicking a buttonClicking a button Loading a formLoading a form Exiting a formExiting a form
Triggers can be associated with:Triggers can be associated with: An entire form (form level)An entire form (form level) A block (block level)A block (block level) A specific form item (item levelA specific form item (item level))
Form TriggersForm Triggers
4Eyad Alshareef
Using Sequences to Using Sequences to Generate Generate
Primary Key ValuesPrimary Key Values Form can be set up to automatically retrieve next Form can be set up to automatically retrieve next
sequence number and populate primary key fieldsequence number and populate primary key field Form triggers respond to user events or system Form triggers respond to user events or system
actionsactions To create a trigger, specify:To create a trigger, specify:
Trigger’s object (i.e. specific button)Trigger’s object (i.e. specific button) Trigger event (i.e. button press)Trigger event (i.e. button press) Code that executesCode that executes
Use PRE-FORM event to perform action when form Use PRE-FORM event to perform action when form loadsloads
Use Triggers dialog box to create triggers for Use Triggers dialog box to create triggers for objectsobjects
7Eyad Alshareef
Creating Form Triggers Creating Form Triggers (continued)(continued)
Triggers dialog boxTriggers dialog box Shows all block events that can have Shows all block events that can have
associated triggersassociated triggers Search using wildcardsSearch using wildcards
PL/SQL Editor PL/SQL Editor Environment for writing, compiling, and Environment for writing, compiling, and
editing PL/SQL programsediting PL/SQL programs Source code paneSource code pane Status lineStatus line
8Eyad Alshareef
Triggers Dialog BoxTriggers Dialog Box
9Eyad Alshareef
Creating a trigger:Creating a trigger: select the form or form item eventselect the form or form item event type the trigger codetype the trigger code
Referencing a form item in PL/SQL code:Referencing a form item in PL/SQL code: ::block_nameblock_name..item_nameitem_name
Triggers are compiled before a form is Triggers are compiled before a form is runrun
Using Form TriggersUsing Form Triggers
10Eyad Alshareef
Create a block-level WHEN-Create a block-level WHEN-CREATE-RECORD triggerCREATE-RECORD trigger
Trigger PL/SQL code:Trigger PL/SQL code:SELECT SELECT sequence_namesequence_name.NEXTVAL.NEXTVAL
INTO :INTO :block_nameblock_name..item_nameitem_name
FROM DUAL;FROM DUAL;
Using Sequences in Using Sequences in FormsForms
12Eyad Alshareef
List of legal values that can be List of legal values that can be selected for use in a form fieldselected for use in a form field
LOVdisplay
LOVcommandbutton
Form Lists of Values Form Lists of Values (LOVs)(LOVs)
13Eyad Alshareef
Creating a List of Values Creating a List of Values (LOV)(LOV)
Use a list of values (LOV) to eliminate user errorsUse a list of values (LOV) to eliminate user errors Pop-up list allows user to select value from list of Pop-up list allows user to select value from list of
choices rather than typingchoices rather than typing User can open LOV by:User can open LOV by:
Typing Ctrl-L with cursor in LOV text fieldTyping Ctrl-L with cursor in LOV text field Click Edit then Display List from Forms Services menuClick Edit then Display List from Forms Services menu Clicking command button with attached trigger to Clicking command button with attached trigger to
open LOVopen LOV LOV allows user to search for values using LOV allows user to search for values using
wildcardswildcards LOV data values come from a record groupLOV data values come from a record group
15Eyad Alshareef
Creating an LOVCreating an LOV To create LOV:To create LOV:
Use LOV WizardUse LOV Wizard Manually create using Object NavigatorManually create using Object Navigator
LOV can contain one or more columnsLOV can contain one or more columns LOV appearance can be customized LOV appearance can be customized
using layout wizardusing layout wizard Create a button on main form to Create a button on main form to
launch LOV using button tool, attach launch LOV using button tool, attach form trigger to button that opens LOVform trigger to button that opens LOV
16Eyad Alshareef
1.1. Use the LOV Wizard to:Use the LOV Wizard to: Specify the LOV display records Specify the LOV display records
using a SQL queryusing a SQL query Format the LOV displayFormat the LOV display Attach the LOV to a form text itemAttach the LOV to a form text item
2.2. Change the LOV and record group Change the LOV and record group name in the Object Navigatorname in the Object Navigator
Creating an LOV Using Creating an LOV Using the LOV Wizardthe LOV Wizard
17Eyad Alshareef
Opening the LOV DisplayOpening the LOV Display
Place the insertion point in the text Place the insertion point in the text item to which the LOV is attacheditem to which the LOV is attached
Press CTRL+L, or from Edit menu of Press CTRL+L, or from Edit menu of the form choose the option ‘Display the form choose the option ‘Display List’List’
18Eyad Alshareef
Create a trigger for the button Create a trigger for the button that does the following:that does the following:1.1. Places the form insertion point in the Places the form insertion point in the
text item to which the LOV is attached:text item to which the LOV is attached:
GO_ITEM(‘IN_VID’);GO_ITEM(‘IN_VID’);
2.2. Executes the LIST_VALUES command: Executes the LIST_VALUES command:
LIST_VALUES;LIST_VALUES;
LOV Command Button LOV Command Button TriggerTrigger
19Eyad Alshareef
Create an LOVCreate an LOV Right-click anywhere in module Right-click anywhere in module
REGISTRATION and select LOV REGISTRATION and select LOV wizardwizard
Select record group based on a Select record group based on a queryquery
20Eyad Alshareef
Create an LOVCreate an LOV Type in a query that would retrieve all Type in a query that would retrieve all
records from table course (do not put a records from table course (do not put a semi-column at the end)semi-column at the end)
Here you will may be asked to log into the Here you will may be asked to log into the DBDB
21Eyad Alshareef
Create an LOVCreate an LOV
Select all the columns that you want to Select all the columns that you want to appear in you LOVappear in you LOV
22Eyad Alshareef
Create an LOVCreate an LOV Specify the return value for Specify the return value for
COURSENAME fieldCOURSENAME field Return value is a field where the course name Return value is a field where the course name
from your LOV will be insertedfrom your LOV will be inserted
23Eyad Alshareef
Create an LOVCreate an LOV
Specify title and dimensionsSpecify title and dimensions Specify the number of rows displayed at Specify the number of rows displayed at
onceonce
24Eyad Alshareef
Select COURSENAME as assigned Select COURSENAME as assigned valuevalue
Complete your LOVComplete your LOV
Create an LOVCreate an LOV
25Eyad Alshareef
To test your To test your LOV:LOV: Run the formRun the form Click on Click on
CourseName CourseName fieldfield
Press CTRL+LPress CTRL+L
Create an LOVCreate an LOV
26Eyad Alshareef
Close your form in Close your form in the browserthe browser
Return to the Form Return to the Form buikder, Layout buikder, Layout editoreditor
Click on the Control Click on the Control Button item in the Button item in the toolbar on the left toolbar on the left and drag it to a and drag it to a desired location on desired location on your canvasyour canvas
Name your button Name your button using Property using Property palettepalette
Create an LOV control Create an LOV control buttonbutton
27Eyad Alshareef
Right click on the button, and open PL/SQL Right click on the button, and open PL/SQL editoreditor
Select Type – TRIGGER, Name – Select Type – TRIGGER, Name – WHEN_MOUSE_CLICKEDWHEN_MOUSE_CLICKED
Type in code the code belowType in code the code below
Create an LOV control Create an LOV control buttonbutton
Eyad Alshareef 28
Alternate Form Alternate Form Input ItemsInput Items
Radio buttonsRadio buttons
Check boxesCheck boxes
29Eyad Alshareef
Limits user to one of two or more Limits user to one of two or more related, mutually exclusive choicesrelated, mutually exclusive choices
Radio ButtonsRadio Buttons
30Eyad Alshareef
Related radio Related radio buttons are part buttons are part of a of a radio groupradio group
Radio group
Individual relatedradio buttons
Radio GroupsRadio Groups
31Eyad Alshareef
Creating Radio ButtonsCreating Radio Buttons
Radio buttonsRadio buttons Represent data fields whose values must be Represent data fields whose values must be
one of small set of mutually exclusive one of small set of mutually exclusive selectionsselections
Exist within radio groupExist within radio group Select item type in Layout WizardSelect item type in Layout Wizard
Manually create radio buttonsManually create radio buttons Use Radio Button toolUse Radio Button tool Change properties using Property PaletteChange properties using Property Palette Align edges using Align Objects dialog boxAlign edges using Align Objects dialog box
32Eyad Alshareef
1.1. Create the form using the Data Block Create the form using the Data Block and Layout Wizardsand Layout Wizards
2.2. Open the item Property Palette, and Open the item Property Palette, and change the Item Type value to Radio change the Item Type value to Radio GroupGroup
3.3. Draw and format the radio buttons on Draw and format the radio buttons on the canvasthe canvas
4.4. Modify the radio button propertiesModify the radio button properties
5.5. Modify the radio group propertiesModify the radio group properties
Creating a Radio GroupCreating a Radio Group
33Eyad Alshareef
Name: how the button is referenced within the form
Name: how the button is referenced within the form
Label: description that appears next to the button on the canvas
Label: description that appears next to the button on the canvas
Radio Button Value: associated data value in the database
Radio Button Value: associated data value in the database
Important Radio Button Important Radio Button PropertiesProperties
34Eyad Alshareef
Name: how the radio group is referenced within the form
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
Initial Value: data value of the radio button within the radio group that is selected when the form first appears
Important Radio Group Important Radio Group PropertiesProperties
35Eyad Alshareef
Check BoxesCheck Boxes
Used to represent fields that can Used to represent fields that can have one of two valueshave one of two values
Check box caption is interpreted Check box caption is interpreted as TRUE or FALSEas TRUE or FALSE If checked, caption is trueIf checked, caption is true If cleared, caption is falseIf cleared, caption is false
37Eyad Alshareef
1.1. Create the form using the Data Create the form using the Data Block and Layout WizardsBlock and Layout Wizards
2.2. Open the item Property Palette, Open the item Property Palette, and change the Item Type value and change the Item Type value to Check Boxto Check Box
3.3. Modify the item propertiesModify the item properties
Creating a Check BoxCreating a Check Box
38Eyad Alshareef
Creating Check BoxesCreating Check Boxes
Check boxes Check boxes Represent data values that can have Represent data values that can have
only one of two opposing valuesonly one of two opposing values Label represents one valueLabel represents one value Value when CheckedValue when Checked
Value that will be saved in database if Value that will be saved in database if checkbox checkedcheckbox checked
Value when UncheckedValue when Unchecked
39Eyad Alshareef
Value when Checked: data value of the item when the box is checked
Value when Checked: data value of the item when the box is checked
Important Check Box Important Check Box PropertiesProperties
Label: description that appears next to the check box on the canvas
Label: description that appears next to the check box on the canvas
Value when Unchecked: 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
Check Box Mapping of Other Values: check box status when form first opens, or when new blank record is added
40Eyad Alshareef
Convert Major into List Convert Major into List ItemItem
In the Property palette, change item In the Property palette, change item type to list itemtype to list item