chap06.ppt

44
A Guide to Oracle9i 1 Creating Custom Forms Chapter 6

Upload: bansaladiti03

Post on 25-Nov-2015

6 views

Category:

Documents


0 download

DESCRIPTION

presentation

TRANSCRIPT

  • Creating Custom FormsChapter 6

    Guide to Oracle 9i

  • Lesson A ObjectivesLearn about custom formsCreate a custom formCreate command buttons that use form triggers to manipulate dataUse the Forms Debugger to find form logic and runtime errorsLearn how form triggers workCreate form navigation triggers

    Guide to Oracle 9i

  • Custom FormsDisplay the data fields from a variety of database tablesContain programs that support organizational processesNot associated with one tableWhen 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

    Guide to Oracle 9i

  • Creating a Custom FormManually create the form canvas in the Object NavigatorCreate the form items by painting the items on the canvas, using tools on the Layout Editor tool paletteWrite the code that controls the form functionsUse a control data blockNot associated with one database tableContains manually drawn form itemsControlled with form triggers

    Guide to Oracle 9i

  • System Date and Time Variables

    Guide to Oracle 9i

  • Creating Command ButtonsCreate a command button by drawing the button on the canvas using the Button toolCreate button triggers manually for custom formsTrigger fires on WHEN-BUTTON-PRESSED eventIf multiple buttons execute similar actions (like clearing a form) create a separate program unit for this action

    Guide to Oracle 9i

  • Sample Button Trigger Commands

    Guide to Oracle 9i

  • Using the Forms Debugger to Find Runtime ErrorsUse the Forms Debugger to find runtime errors that occur while a form is runningIdentify the program line that is causing the error, and examine the variable values used within the command that has the errorInvestigate the nature of the error by looking up the error code explanationError codes with the FRM- prefix are Forms Builder error codesError codes with the ORA- prefix are generated by the DBMSLook up error code on otn.oracle.com

    Guide to Oracle 9i

  • Using the Forms DebuggerClick the Run Form Debug button on the Forms Builder toolbarSet a breakpoint, which pauses execution on a specific program commandTo debug:Examine the current values of all program variablesStep through the program commands to observe the execution pathExamine variable values to see how the values change

    Guide to Oracle 9i

  • Setting a Breakpoint

    Guide to Oracle 9i

  • Forms Debug Console Windows

    Guide to Oracle 9i

  • Viewing Text Item Values

    Guide to Oracle 9i

  • Form Trigger Categories

    Guide to Oracle 9i

  • Trigger PropertiesTrigger timing:Specifies when a trigger firesCan be just before, during, or after its triggering eventBefore: PRE-After: POST-During: WHEN-, ON-, KEY-Trigger scopeDefines where an event must occur in order for trigger to fireIncludes the object to which the trigger is attached, and contained objects

    Guide to Oracle 9i

  • Trigger PropertiesTrigger execution hierarchy:Defines which trigger fires when an object within a form object contains the same trigger that the form object containsCan specify custom execution hierarchy

    Guide to Oracle 9i

  • Directing Form External NavigationForm focus: currently selected item has form focusExternal navigation:Occurs when the user causes the form focus to change by making a different form item activeInternal navigation:Occurs as a result of internal form code that responds to external navigation operations or trigger commandsUse external navigation to:Specify initial form focus when form opensSpecify tab order

    Guide to Oracle 9i

  • Setting Tab Order in Object Navigator

    Guide to Oracle 9i

  • Directing External Navigation Using Built-in Subprograms

    Guide to Oracle 9i

  • Lesson B ObjectivesLearn about default system messages and how to suppress themCreate alerts and messages to provide system feedbackCreate applications that avoid user errorsLearn how to trap common runtime errors

    Guide to Oracle 9i

  • System Message Severity Levels

    Guide to Oracle 9i

  • Suppressing MessagesSYSTEM.MESSAGE_LEVEL:Variable used to suppress error messagesSet to 0, 5, 10, 15, 20, 25 to suppress all messages with severity below this levelDefault value is 0Set value in PRE-FORM trigger

    Guide to Oracle 9i

  • Providing System FeedbackCustom message:A short text string displayed on the form message lineUse when the form needs to provide a short, simple message that does not require an acknowledgement from the userTo create: MESSAGE('message_string');Can be up to 200 characters

    Guide to Oracle 9i

  • AlertsDialog box that can display a longer text messageDisplays one or more buttons that allow the user to select between alternatives that execute associated program statementsUse when:Message is longer than 200 charactersUser acknowledgement is requiredUser choice is requiredSee Figure 6-22 for example alert

    Guide to Oracle 9i

  • Displaying an AlertIn 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

    Guide to Oracle 9i

  • Avoiding User ErrorsForms should help users avoid errors by:Validating input valuesProgrammatically disabling form command buttonsDisabling navigation for form text items containing values that users should not change

    Guide to Oracle 9i

  • Text Item Validation

    Guide to Oracle 9i

  • Form Validation TriggersItem validation triggers:Perform complex validationsAssociate with WHEN-VALIDATE-ITEM eventTrigger code tests the current item value to determine if it satisfies the validation conditionIf input not valid, form displays a message and raises a built-in exception named FORM_TRIGGER_FAILURE

    Guide to Oracle 9i

  • Disabling Form Command ButtonsDisable command buttons to prevent users from pressing them before form is in proper stateSET_ITEM_PROPERTY('UPDATE_BUTTON', ENABLED, PROPERTY_FALSE);

    Guide to Oracle 9i

  • Disabling Text Item NavigationPrevent users from modifying primary key valuesMake text item nonnavigable: user cannot press the Tab key to place the insertion point in the text itemTo 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

    Guide to Oracle 9i

  • Trapping Common Runtime ErrorsProvide better error messages for common errorsCreate form-level trigger for ON-ERROR event

    Guide to Oracle 9i

  • Syntax for ON-ERROR Trigger

    Guide to Oracle 9i

  • Lesson C ObjectivesConvert data blocks to control blocksLink data blocks to control blocksCreate a form that has multiple canvasesCreate tab canvasesCreate stacked canvases

    Guide to Oracle 9i

  • Converting a Data Block to a Control BlockSave time by creating a data block and converting to a control blockTo convert data block to control block:Change the data blocks Database Data Block property value to NoChange the Required property value of the text item that represents the data block tables primary key to No

    Guide to Oracle 9i

  • Linking a Data Block to a Control BlockUseful in complex forms with master-detail relationshipsMaster is control block, details are data blocksTo link a control block with a data block:Create the control blockCreate the data blockSpecify the link between the control block and the data blockModify the form triggers to refresh the data block when the underlying data values change

    Guide to Oracle 9i

  • Control/Data Block Form Example

    Guide to Oracle 9i

  • Creating Forms with Multiple CanvasesUse multiple screens to avoid displaying too much informationSingle-form approach: Create one form with multiple canvasesEnables the form to share data among the different canvasesImpossible for multiple programmers to work simultaneously on different canvases of the same applicationMultiple-form approach:Create multiple forms with a different .fmb file for each application canvasWorks well when multiple programmers collaborate to create a complex application

    Guide to Oracle 9i

  • Viewing Canvas and Block Information

    Guide to Oracle 9i

  • Creating Multiple Canvas/Block FormsSpecify block and canvas ordering in Object NavigatorTo navigate to another canvas programmatically, use GO_ITEM to navigate to an item on the canvasRefer to items in triggers with syntax :block_name.item_nameUse caution to make sure items are placed in correct blocks

    Guide to Oracle 9i

  • Creating and Configuring Tab Canvases in FormsMultiple-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 wayDirect a user through a sequence of steps for performing a taskLies on top of a content canvas within the form window.Tab page: An object representing a surface that displays form itemsHas a tab label identifier at the top

    Guide to Oracle 9i

  • Creating a Tab CanvasTo create:Create the formCreate a new content canvas in the formCreate a tab canvas on the content canvasConfigure the tab pages

    Guide to Oracle 9i

  • Creating a Tab Canvas

    Guide to Oracle 9i

  • Creating and Configuring Stacked Canvases in FormsLies on top of a content canvasUse to hide canvas objects and then make the objects appear as neededCreate by:Painting canvas in the desired position on an existing content canvasConfigure stacked canvas propertiesCreate the form items that are to appearWrite 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

    Guide to Oracle 9i

  • Configuring a Stacked Canvas

    Guide to Oracle 9i

  • SummaryControl blocks are created manually and do not represent data from only one tableControl blocks can be created from data blocks to make coding easierForms Debugger is used to find runtime errors in formsUser errors should be avoided by limiting opportunities for errorUser feedback is presented in message line and alert boxesA form may contain more than one canvas; canvases can be organized using tabs or shown and hidden programmatically

    Guide to Oracle 9i