Creating Custom Forms Part A Eyad Alshareef 1











































- Slides: 43

Creating Custom Forms Part A Eyad Alshareef 1

Data Block and Custom Forms n Data block form Based on data blocks that are associated with specific database tables n Reflect the structure of the database n n Custom form Based on control blocks that process data from multiple tables n Reflect business processes rather than the database structure n Eyad Alshareef 2

Introduction to Custom Forms n Custom form Displays data fields from variety of database tables n Contains programs that support organizational processes n Use lists of values (LOVs) to retrieve data values n Manipulate data using form triggers n Eyad Alshareef 3

Identifying the Business Processes and Database Operations Identify processes that form supports n Identify associated database tables n Describe process n Eyad Alshareef 4

Designing the Interface n Visualize how form will look Eyad Alshareef 5

Creating a Custom Form Manually create form canvas in Object Navigator n Create form items by “painting” items on canvas n n n 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 n Start Forms Builder n Create and rename form canvas n Rename form module and form window n Change Title property of form window n n Perform in Visual View in Object Navigator Eyad Alshareef 7

Creating a Control Block n Control data block Also called control block n Data block not associated with particular database table n n Create new data block in Object Navigator Specify data block created manually n Use Ownership View n Eyad Alshareef 8

Creating the Form Items n Create Boilerplate logo image and text n Form text items n Command button items n n Display form in Layout Editor n Draw items on form canvas using tools in tool palette Eyad Alshareef 9

Creating the LOVs n LOV n Retrieve data from database table Use LOV Wizard n Run form n n To test LOV Eyad Alshareef 10

Displaying System Date and Time Values in Form Text Items n System variable n n Variable representing value always available to any form Display value in text item automatically n 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 n Create form triggers associated with buttons n Eyad Alshareef 13

Creating and Configuring Command Buttons n Draw button on canvas using Button tool n n Button tool palette Button group n Buttons should all be same size n Wide enough to accommodate longest button’s label n Draw button with longest label first Eyad Alshareef 14

Creating the Button Triggers n Select Triggers node under button in Object Navigator Click Create button to create trigger n Select trigger event n Specify trigger code n n WHEN-BUTTON-PRESSED button event n Trigger code executes when user clicks button Eyad Alshareef 15

Creating the Button Triggers (continued) n Reference form items: n n : block_name. item_name Clear form text items in form trigger: Use CLEAR_FORM built-in procedure n Create program unit to set value of text items to blank text string n n Procedure n Code block that executes commands to change one or more values Eyad Alshareef 16

Creating the Button Triggers (continued) n Function Code block n Returns single value n n Create program unit: Open Object Navigator n Select Program Units node n Click Create button n n Program unit does not use DECLARE keyword Eyad Alshareef 17

Creating a Custom Form 1. 2. 3. Create the form window and canvas manually Create a control block n n 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 n Can contain SQL INSERT, UPDATE, DELETE, and SELECT commands n Referencing form text item values in triggers: n : block_name. item_name Eyad Alshareef 19

Practice 1 n Create a custom form that has: Employee Name n Employee Salary n Department Name n Create a LOV to retrieve block records n Use triggers to retrieve block records n Create a button that calls a program unit to clear the block. n Eyad Alshareef 20

Creating a custom form n n n 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 n n 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 n n n 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 n Using the toolbox on the left, add Course Name text box and a corresponding prompt: Eyad Alshareef 24

Add text boxes and prompts n n n 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 n n n 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 n Add PL/SQL code to the triggers n Eyad Alshareef 27

Adding PL/SQL code Eyad Alshareef 28

Adding PL/SQL code Create triggers for each of the buttons n Add PL/SQL code to the triggers n Eyad Alshareef 29

Adding PL/SQL code Create triggers for each of the buttons n Add PL/SQL code to the triggers n Eyad Alshareef 30

Adding PL/SQL code Create triggers for each of the buttons n Add PL/SQL code to the triggers n Eyad Alshareef 31

Form Trigger Properties n Trigger activated n n 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 n PREn n n POSTn n Fire just before event successfully completes Fire just after event successfully completes ON-, WHEN-, and KEYn Fire in response to actions Eyad Alshareef 34

Trigger Scope Defines where event must occur in order for associated trigger to fire n Includes object to which trigger attached n n And objects within trigger object Eyad Alshareef 35

Trigger Execution Hierarchy n Defines which trigger fires n 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 n Can specify custom execution hierarchy n Eyad Alshareef 36

Directing Form External Navigation n External navigation n n Form focus n n User causes form focus to change by making different form item active Item currently selected on form Internal navigation n Result of internal form code that responds to external navigation operations or trigger commands Eyad Alshareef 37

Setting the Form Tab Order n Set tab order n Place items in correct order under Items node n In Object Navigator window Eyad Alshareef 38

Directing External Navigation Using Built-in Subprograms n Built-in subprograms Called built-ins n Use to direct external form navigation n n 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