use to validate or perform auditing tasks based on the prior event Key Triggers Fires when the operator presses a specific key or key-sequence. MessageIn response to default On-Error handling messaging events On-Message Navigational In response to navigational Pre-[Form | Block | Record | Text-Item] events Post-[Form | Block | Record | Text-Item] When-New-[Form | Block | Record | Item]Instance Query-time Just before and just after Pre-Query the operator or the Post-Query application executes a query in a block Validation When Forms validates data When-Validate-[Item | Record] after the user enters data and navigates out of the item or record Fires In response to events related to record management in a block.Trigger Categories Triggers may be categorized based on their functions:
Category Block processing Examples When-Create-Record When-Clear-Block When-Database-Record When-Remove-Record Interface In response to events that Key-[all] event occur in the form interface When-Button-Pressed When-[Checkbox | List | Radio]-Changed When-Image-[Activated | Pressed] When-Timer-Expired When-Window-[Activated | Deactivated | Closed | Resized] Master-detail To enforce coordination On-Check-Delete-Master between records in a detail On-Clear-Details block and the master record On-Populate-Details in a master block. use to prepare objects or data for the upcoming event Post-Event Point just following the occurrence of either a When-event or an Onevent.
You can also categorize triggers based on their names: Category When-Event Description Point at which Forms default processing may be augmented with additional tasks or operations On-Event Point at which Forms default processing may be replaced Pre-Event Point just prior to the occurrence of either a When-event or an On-event.
Oracle Forms Developer 10g: Build Internet Applications 13-5
.

However. you must define each trigger at a different level. Also inform them that it is recommended to define On-Error triggers only at form level. then form level. which is based on the CUSTOMERS table. The triggers just display a message indicating the level of the trigger that fires. but it is used here just to illustrate trigger scope. block level. Set EH property to “before” for block level and to “after” for item level. if any. and finally item level. • Before: The trigger fires before firing the same trigger.customer_id). Run the form and insert text into CUSTOMERS. at the next highest level. • After: The trigger fires after firing the same trigger.Execution Hierarchy (continued) Execution hierarchy (EH) is a trigger property that specifies how the current trigger code should execute if there is a trigger with the same name defined at a higher level in the object hierarchy. you can fire more than one trigger of the same type due to a single event. if any. Run the form and cause the error as before. Point out that there are On-Error triggers defined at form level. Point out to students that setting EH at form level would not affect the execution order. and item level (for CUSTOMERS. Settings for execution hierarchy are: • Override: Only the trigger most specific to the cursor location fires. This is the default.
Oracle Forms Developer 10g: Build Internet Applications 13-13
. This causes the On-Error triggers to fire according to the EH settings: first block level. This causes the On-Error trigger to fire only for the item level. since there is no higher level trigger. Instructor Note Demonstration Open the form EH_DEMO.customer_id. at the next highest level. then navigate to the next item. In the cases of Before and After. Setting EH for form level triggers has no effect.fmb.

To ensure that performance is not impacted more than necessary. The examples are not complete triggers.
3. References to items should be prefixed by the name of the owning Forms Builder block.MODE = ’NORMAL’ THEN ok_to_leave_block := TRUE. and the contents must be in uppercase (’NORMAL’.country’). The following example creates a global variable named country and initializes it with the value TURKEY:
Default_Value(’TURKEY’.
2.
4. END IF.’GLOBAL. Parameters defined at design-time have the prefix parameter:
IF :PARAMETER.id. References to global variables must be prefixed by the word global.Forms Builder Variables (continued) In each of the following examples of using Forms Builder variables.starting_point = 2 THEN GO_BLOCK(’BLOCK2’). which prevents ambiguity when items of the same name exist in different blocks.
Initializing Global Variables with Default Value You can use the DEFAULT_VALUE built-in to assign a value to a global variable.customer_id := :BLOCK1. References to system variables must be prefixed by the word System. note that a colon (:) prefixes Forms Builder variables.) separates the components of their name. This is also more efficient than the item name alone:
:BLOCK3. They may be created as the result of an assignment:
:GLOBAL.built-in procedure END IF. and a period (.product_id := :BLOCK2.
Removing Global Variables You can use the ERASE built-in to remove a global variable. If the value of the indicated variable is not null. -. Examples 1. always erase any global variable when it is no longer needed.product_id. not ’normal’):
IF :SYSTEM. Forms Builder creates the global variable if it does not exist. Globals always allocate 255 bytes of storage. DEFAULT_VALUE does nothing.
Oracle Forms Developer 10g: Build Internet Applications 14-15
.

and accessing attributes of OLE2 automation objects. ORA_FFI. Forms Builder provides the following packages:
Package DDE DEBUG EXEC_SQL FBEAN FTREE OLE2 ORA_FFI ORA_JAVA ORA_NLS ORA_PROF TEXT_IO TOOL_ENV TOOL_ERR TOOL_RES WEB Description Provides Dynamic Data Exchange support Provides built-ins for debugging PL/SQL program units Provides built-ins for executing dynamic SQL within PL/SQL procedures Provides built-ins to interact with client-side Java beans Provides built-ins for manipulating hierarchical tree items Provides a PL/SQL API for creating. not on the client side. For example. you would need to provide similar functionality in a JavaBean. manipulating. function on the application server side. Provides built-ins for calling out to foreign (C) functions from PL/SQL Enables you to call Java procedures from PL/SQL Enables you to extract high-level information about your current language environment Provides built-ins for tuning PL/SQL program units Provides built-ins to read and write information to and from files Enables you to interact with Oracle environment variables Enables you to access and manipulate the error stack created by other built-in packages such as Debug Provides built-ins to manipulate resource files Provides built-ins for the Web environment
Note: Some of these packages.Adding Functionality with Built-In Subprograms (continued) In addition to the standard extensions. To interact with the client.
Oracle Forms Developer 10g: Build Internet Applications 14-17
. TOOL_ENV enables you to get and set environment variables on the application server. and TEXT_IO. such as OLE2.

.Using Built-In Definitions (continued) Note: A subprogram can be either a procedure or a function.
DECLARE customer_chosen BOOLEAN. .
Oracle Forms Developer 10g: Build Internet Applications 14-20
. Built-in subprograms are therefore called in two distinct ways: • Built-in procedures: Called as a complete statement in a trigger or program unit with mandatory arguments. This is not a complete trigger. You can use the find feature in the Object Navigator to bypass this overload in the list. Demonstration: Use SHOW_LOV to demonstrate how you can paste prototype syntax for a built-in from the Object Navigator into a trigger or program unit. Again. Example The SHOW_LOV built-in is a function that returns a Boolean value (indicating whether the user has chosen a value from the LOV). It might be called as part of an assignment to a boolean variable. in a trigger or program unit. Highlight an example using a built-in. .
Instructor Note Point out the overloadings in the list within the Object Navigator. then close Help and paste in the PL/SQL Editor. • Built-in functions: Called as part of a statement. the function call must include any mandatory arguments. Point out how you can locate the built-in in Help. BEGIN customer_chosen := SHOW_LOV(’customer_list’). Copy it. at a position where the function’s return value will be used.

if in ENTERQUERY mode. If there are changes to commit.
Oracle Forms Developer 10g: Build Internet Applications 14-22
. Forms Builder prompts the operator to commit them before continuing EXECUTE_QUERY processing. or retrieves an existing string from the editor SHOW_LOV function Invokes a specified LOV and returns a Boolean value that indicates whether user selected a value from the list SHOW_VIEW procedure Displays the indicated canvas at the coordinates specified by the X Position and Y Position of the canvas property settings. cancels query GET_ITEM_PROPERTY Returns specified property values for the indicated item function GO_BLOCK procedure Navigates to the specified block GO_ITEM procedure Navigates to the specified item HIDE_VIEW procedure Hides the indicated canvas LIST_VALUES procedure Invokes the LOV attached to the current item MESSAGE procedure Displays specified text on the message line SET_ITEM_PROPERTY Changes setting of specified property for an item procedure SHOW_ALERT function Displays the given alert and returns a numeric value when the operator selects one of three alert buttons SHOW_EDITOR procedure Displays the specified editor at the given coordinates and passes a string to the editor. the Forms Builder prompts the operator to commit them before continuing ENTER_QUERY processing. If the view is already displayed. and fetches a number of selected records. EXECUTE_QUERY procedure Clears the current block. If there are changes to commit. EXIT_FORM procedure If in normal mode. opens a query. Operators can then specify query conditions before executing the query with a menu or button command. SHOW_VIEW raises it in front of any other views in the same window. exits current form.Useful Built-Ins (continued)
Built-in Subprogram
Description
EDIT_TEXTITEM procedure Invokes the Form Runtime item editor for the current text item ENTER_QUERY procedure Clears the current block and creates a sample record.

11. Ensure. 7. Test to see that the LOV is invoked when you press the Account_Mgr_Lov_Button and that the form exits when you close the Customer Information window. You might decide to advertise Help only while the cursor is in certain items.Hide_Help_Button that hides the CV_HELP. Save. use the Smart Triggers feature. and run the form. The stacked canvas. that the first entered item in the form is one that will not be obscured by CV_HELP.TRIGGER_BLOCK to determine what block the cursor is in when the trigger fires. if appropriate. 4. of course. and use the “Paste Name and Arguments” feature. Find the relevant built-in in the Object Navigator under built-in packages. Test to see that the LOV is invoked when you press the Product_Lov_Button. Create a When-Button-Pressed trigger on CONTROL. The CV_HELP canvas. and EXECUTE_QUERY to automatically execute a query. could also be shown in its own window.Show_Help_Button that uses the SHOW_VIEW built-in to display the CV_HELP. or move the stacked canvas to a position that does not overlay enterable items. compile. is displayed only if the current item will not be obscured. Write a trigger that exits the form when the Exit_Button is selected. Write a form-level When-Window-Closed trigger to hide the WIN_INVENTORY window if the user attempts to close it. Save. 2. at least. Create a When-Button-Pressed trigger on CONTROL. 8. Use the HIDE_VIEW built-in to achieve this. CV_HELP. Save and compile the form. 6. and run the form. write a trigger to display the Account_Mgr_Lov when the Account_Mgr_Lov_Button is selected. write a trigger to display the Products_Lov when the Product_Lov_Button is selected and that the form exits when you press the Exit_Button. Click Run Form to run the form and test the changes.Practice 14
1. 5. In the CUSTGXX form. In the ORDGXX form. 10. and to exit the form if the user attempts to close the WIN_ORDER window. Hint: Use the system variable :SYSTEM. To create the When-Button-Pressed trigger. 3. compile. Create a When-Window-Closed trigger at the form level in order to exit form. 9.Stock_Button that uses the GO_BLOCK built-in to display the INVENTORIES block.
Oracle Forms Developer 10g: Build Internet Applications 14-28
. Create a When-Button-Pressed trigger on CONTROL.

v_num6 NUMBER := 8.” The syntax must be correct because everything compiled correctly. If a more complex demo is desired.fmb in Forms Builder to show the students how to use the debugger.wrong value should be 6 */ BEGIN v_total := v_num3 * v_num6.push_button1 on the executable line that calls the procedure. • Before proceeding. now that the debugger is integrated into Forms Builder. Find the problem in the code (v_num6 is incorrectly set to 8 instead of 6). When you click Debug Example in the form. • Click Debug Example in the form. open and run EMPLOYEES. the expected results were “128. Variables. • If not already displayed. • The Cause Exception button in the form causes a 1422 exception. So. The XYZ procedure adds the result to the xyz_param and displays it in the console at the bottom of the form window. bring up the Debug Console and demonstrate the Breakpoints. • Set a breakpoint in the When-Button-Pressed trigger for Block1. • Return to the form to see that the correct result of 128 is now obtained.Debug Example (continued) 5. and Stack panels. v_total := v_total + abc_param. The developer needs to debug the code to find why it produced the wrong results. change the value of the variable to 6. Then. this is no longer possible.
Instructor Note Demonstration Open the form DebugDemo. in the Variables panel. v_num3 NUMBER := 3. • Examine the Stack values for the xyz_param and v_results parameters (as well as system variables). • First run the form normally.
FUNCTION abc (abc_param IN NUMBER) RETURN NUMBER IS v_total NUMBER := 0. END abc. Everything looks normal in the xyz procedure.
Oracle Forms Developer 10g: Build Internet Applications 15-19
. there must be something wrong in the logic of the application code within the form. Step through each of the opening assignment statements. you could change PL/SQL code on the fly in the debugger. • Click Run Form Debug to run the DebugDemo form in Debug mode. RETURN v_total. and the form itself is running in a three-tier environment. In previous versions of Forms. However. • The XYZ procedure now displays in the PL/SQL Editor. • Click Step Into to enter the ABC function. with “=>” to mark current position at the beginning of the executable code. so select that as the exception on which to break. the PL/SQL would need to be corrected. “134” displays at the bottom of the screen (console). The program stops at the breakpoint. /*-. • Click Step Into in the Debugger to advance into the XYZ procedure. However.fmb: • The various buttons in this form enable you to demonstrate the Package and Break on Exceptions windows. Point out to students that to correct the problem permanently. click Go.

IF v_lov = TRUE THEN MESSAGE('You have just selected a‘||p_text).txt file:
PROCEDURE list_of_values(p_lov in VARCHAR2. Look at the Variables panel to see the value of the parameters you passed to the procedure. In this form. Import code from the pr15_1. 4. BEGIN v_lov:= SHOW_LOV(p_lov). Modify the When-Button-Pressed trigger of CONTROL. Misspell the parameter to pass the LOV name. END IF. Press the LOV button for the Account Manager. Try stepping through the code to monitor its progress. 3. and you receive a message that ‘You have just cancelled the List of Values’. Now click Run Form Debug.
2.Practice 15 1. Notice that the LOV does not display.p_text in VARCHAR2) IS v_lov BOOLEAN. END. Compile your form and click Run Form to run it. and the value of the p_lov variable in the procedure.FMB file. and investigate the call stack. create a procedure that is called List_Of_Values. Set a breakpoint in your When-Button-Pressed trigger. Open your CUSTGXX. How would this information help you to figure out where the code was in error?
Oracle Forms Developer 10g: Build Internet Applications 15-22
. ELSE MESSAGE('You have just cancelled the List of Values').Account_Mgr_LOV_Button in order to call this procedure.

Trigger When-Button-Pressed When-Checkbox-Changed When-Custom-Item-Event When-Radio-Changed When-Image-Pressed When-Image-Activated When-List-Changed When-List-Activated When-Tree-Node-Activated When-Tree-Node-Expanded When-Tree-Node-Selected
Firing Event User clicks with mouse or uses function key to select User changes check box state by clicking or by pressing a function key User selects or changes the value of a JavaBean component User selects different button. or deselects current button. in a radio group User clicks image item User double-clicks image item User changes value of a list item User double-clicks element in a T-list User double-clicks a node or presses [Enter] when a node is selected User expands or collapses a node User selects or deselects a node
Oracle Forms Developer 10g: Build Internet Applications 16-4
. as previously described. They can be defined at any scope.Item Interaction Triggers (continued) The following triggers fire due to user interaction with an item.

0)) INTO v_unpaid_orders FROM orders o. IF v_unpaid_orders > :customers. END. Note: Displaying alerts is discussed in the next lesson. BEGIN SELECT SUM(nvl(unit_price. If so.Unpaid credit orders have status between 4 and 9 AND (o. • Use Customer ID 101. order_items i WHERE o. Run the customer.Credit_Limit. For example. • We will discuss using SELECT statements in triggers in the lesson on query triggers.0)*nvl(quantity.customer_id = :customers. may not fit with what would exist in the real world. • Explain the actions in the trigger code. v_unpaid_orders NUMBER. Instructor Note Demonstration • Use the customers. You can click the Orders button to show the customer’s outstanding orders.order_id = i. Note: The data included in the common schema.credit_limit THEN n := SHOW_ALERT('credit_limit_alert').order_id -. a message warns the user. because this customer has some outstanding credit orders.customer_id AND o. When the user changes the credit limit.fmb file to show the When-Radio-Changed trigger on Credit_Limit. used as a basis for the examples and practices in this course.
Oracle Forms Developer 10g: Build Internet Applications 16-6
. DECLARE n NUMBER.fmb file to show the functionality of the trigger.Command Types in Item Interaction Triggers (continued) Example of When-Radio-Changed When-Radio-Changed trigger on :CUSTOMERS.order_status < 10).order_status > 3 AND o. An alert displays to warn that the new credit limit has been exceeded. Click the Account Information tab and change the customer’s credit limit to Low. END IF. most customers with outstanding credit orders actually exceed their set credit limits. this trigger immediately confirms whether the customer has outstanding orders exceeding the new credit limit.

In both cases. x. x. and what the x and y coordinates are where its window should appear: SHOW_LOV( ’lov_name’. y ) You should note that either the LOV name (in quotes) or the LOV ID (without quotes) can be supplied in the first argument. Internal IDs are a more efficient way of identifying an object. Use SHOW_LOV with a single button for the whole form. However. y ) SHOW_LOV( lov_id. Instructor Note Use LIST_VALUES with one button for each item that has an LOV. invokes the LOV of the current item. there are arguments that let you define which LOV is to be displayed.
Oracle Forms Developer 10g: Build Internet Applications 16-10
. set the Keyboard Navigable and Mouse Navigate properties of the button to No.Defining Functionality for Noninput Items (continued) SHOW_LOV Function This built-in function. without arguments. Note: The lov_id is a PL/SQL variable where the internal ID of the object is stored.

Because SHOW_LOV returns TRUE when the user selects a record. END LOOP. the cursor needs to reside in the text item that is attached to the LOV. With SHOW_LOV. LOOP EXIT WHEN SHOW_LOV( ’customer_lov’ ).Using the SHOW_LOV Function (continued) • Switch off the button’s Mouse Navigate property of the button. When using LIST_VALUES. until the function returns TRUE. the LOV redisplays until they do so. this also maintains the cursor to in its original location after the LOV is closed. wherever that may be.
Oracle Forms Developer 10g: Build Internet Applications 16-12
. MESSAGE(’You must select a value from list’). Example This When-Button-Pressed trigger on the Customer_Lov_Button invokes an LOV in a PL/SQL loop.

READ_IMAGE_FILE(’filename’. WRITE_IMAGE_FILE. default path is assumed) File type of the image (You can use ANY as a value.
Oracle Forms Developer 10g: Build Internet Applications 16-14
. is also available.Image Items (continued) READ_IMAGE_FILE Procedure This built-in procedure lets you load an image file.
Parameter filename filetype
item_name
Description Image file name (without a specified path. If you need to write an image file to the file system on the client. into an image item. you must explicitly identify the item_name parameter.’item_name’). but it is recommended to set a specific file type for better performance. • The WRITE_IMAGE_FILE built-in procedure writes an image file to the application server file system. If you omit filetype. use a JavaBean.) (This parameter is optional.’filetype’.)
Note • The filetype parameter is optional in READ_IMAGE_FILE. Refer to online Help for file types. in a variety of formats. • The reverse procedure.) Name of the image item (a variable holding the Item_id is also valid for this argument.

Populating Hierarchical Trees (continued) SET_TREE_PROPERTY Procedure This built-in procedure can be used to change certain properties for the indicated hierarchical tree item. It can also be used to populate the indicated hierarchical tree item from a record group. Ftree.Set_Tree_Property(item_name, Ftree.property, value);
Parameter item_name Description Specifies the name of the object created at design time. The data type of the name is VARCHAR2. A variable holding the Item_id is also valid for this argument. Specifies one of the following properties: RECORD_GROUP: Replaces the data set of the hierarchical tree with a record group and causes it to display QUERY_TEXT: Replaces the data set of the hierarchical tree with a SQL query and causes it to display ALLOW_EMPTY_BRANCHES: Possible values are PROPERTY_TRUE and PROPERTY_FALSE Specifies the value appropriate to the property you are setting.

property

value

You can add data to a tree view by: • Populating a tree with values contained in a record group or query by using the POPULATE_TREE built-in • Adding data to a tree under a specific node by using the ADD_TREE_DATA built-in • Modifying elements in a tree at run time by using built-in subprograms • Adding or deleting nodes and the data elements under the nodes Example This code could be used in a When-Button-Pressed trigger to initially populate the hierarchical tree with data. The example locates the hierarchical tree first. Then, a record group is created and the hierarchical tree is populated.
DECLARE htree ITEM; v_ignore NUMBER; rg_emps RECORDGROUP; BEGIN htree := Find_Item('tree_block.htree3'); rg_emps := Create_Group_From_Query('rg_emps', 'select 1, level, last_name, NULL, to_char(employee_id) ' ||' from employees ' || 'connect by prior employee_id = manager_id ' || 'start with job_id = ''AD_PRES'''); v_ignore := Populate_Group(rg_emps); Ftree.Set_Tree_Property(htree, Ftree.RECORD_GROUP,rg_emps); END;

Displaying Hierarchical Trees The Record Group or Query The columns in a record group or query that are used to populate a hierarchical tree are: • Initial state: 0 (not expandable, 1 (expanded), or -1 (collapsed) • Node tree depth: Use LEVEL pseudocolumn • Label for the node: What the user sees • Icon for the node: Picture displayed, if any • Data: Actual value of the node

Interacting with JavaBeans In Lesson 10, you learned how to add a JavaBean to a form using the Bean Area item. The bean that you add to a form may have a visible component on the form itself, such as a Calendar bean that has its own button to invoke the bean. However, JavaBeans (such as the ColorPicker bean) do not always have visible component, so you may need to create a button or other mechanism to invoke the bean. Regardless of whether the bean is visible in the bean area, there must be some communication between the run-time form and the Java classes that comprise the bean. First, the form must be made aware of the bean, either by setting its Implementation Class property at design time or by registering the bean and its events at run time. Once the form knows about the bean, the form communicates to the bean by: • Invoking the methods of the bean • Getting and setting properties of the bean The bean communicates to the form by: • Sending an event, such as the fact that the user selected a date or color • Sending a list containing information needed by the form, such as what date or color was selected • Returning a value from an invoked method

Oracle Forms Developer 10g: Build Internet Applications 16-19

Interacting with JavaBeans

The FBEAN package provides built-ins to: • • • • Register the bean Invoke methods of the bean Get and set properties on the bean Subscribe to bean events

Interacting with JavaBeans (continued) The FBEAN package The FBEAN package contains Forms built-ins that enable you to code interactions with JavaBeans in PL/SQL, eliminating the need to know Java in order to communicate with the bean. Many of the built-ins take some of the same arguments: • Item Name or Item Id (obtained with the FIND_ITEM built-in): The first argument for most of the FBEAN built-ins, referred to on the next page simply as ITEM. • Item Instance: A reference to which instance of the item should contain the bean. This is applicable where the Bean Area is part of a multi-row block and more than one instance of the Bean Area is displayed. This is referred to on the next page as INSTANCE. You can use the value ALL_ROWS (or FBEAN.ALL_ROWS) for the Item Instance value to indicate that command should apply to all of the instances of this Bean Area in the block. Note: This refers to the UI instance of the Bean Area, not the row number in the block. For example, in a block with 5 rows displayed and 100 rows queried, there will be 5 instances of the bean numbered 1 through 5, not 100 instances. • Value: Can accept BOOLEAN, VARCHAR2, or NUMBER datatypes.

Oracle Forms Developer 10g: Build Internet Applications 16-20

Interacting with JavaBeans (continued) The FBEAN package (continued) Some of the built-ins in the FBEAN package are: • GET_PROPERTY(ITEM,INSTANCE,PROPERTY_NAME)(returns VARCHAR2): Function that retrieves the value of the specified property • SET_PROPERTY(ITEM,INSTANCE,PROPERTY_NAME,VALUE): Sets the specified property of the bean to the value indicated • INVOKE(ITEM,INSTANCE,METHOD_NAME[,ARGUMENTS]): Invokes a method on the bean, optionally passing arguments to the method • REGISTER_BEAN(ITEM,INSTANCE,BEAN_CLASS): Registers the bean with the form at run time, making all its exposed attributes and methods available for the form’s bean item (The last argument is the full class name of the bean, such as 'oracle.forms.demos.beans.ColorPicker'.) • ENABLE_EVENT(ITEM,INSTANCE,EVENT_LISTENER_NAME, SUBSCRIBE); the last argument is a BOOLEAN indicating whether to subscribe (TRUE) or unsubscribe (FALSE) to the event. Remember to precede calls to any of these built-ins with the package name and a dot, such as FBEAN.GET_PROPERTY(…). You can pass arguments to these built-ins as either a delimited string or as an argument list. Deploying the Bean Because the bean itself is a Java class or set of Java class files separate from the form module, you need to know where to put these files. You can locate these either: • On the middle-tier server, either in the directory structure referenced by the form applet’s CODEBASE parameter or in the server’s CLASSPATH. CODEBASE is by default the forms90\java subdirectory of ORACLE_HOME. • If using JInitiator, in a JAR file in the middle-tier server’s CODEBASE directory, and included in the ARCHIVE parameter so that the JAR file is downloaded to and cached on the client. For example: archive_jini=f90all_jinit.jar,colorpicker.jar (The CODEBASE and ARCHIVE parameters are set in the formsweb.cfg file.) Instructor Note When the JavaBean is registered, its properties are given a name that is derived from the JavaBean setters and getters for that property. For example, the Juggler JavaBean has a rate property exposed through the bean methods getAnimationRate and setAnimationRate. Once the bean is registered with FBEAN.REGISTER_BEAN, the custom property animationRate is made available for that Bean Area item in the form. To see all the methods and properties of the JavaBean, you can use FBEAN.SET_LOGGING_MODE to make the information appear on the Java Console.

Interacting with JavaBeans (continued) Responding to Events When a user interacts with a JavaBean at run time, it usually causes an event to occur. You can use FBEAN.ENABLE_EVENT to register a listener for the event, so that when the event occurs Forms will fire the When-Custom-Item-Event trigger. In this trigger, you can code a response to the event. The :SYSTEM.CUSTOM_ITEM_EVENT and :SYSTEM.CUSTOM_EVENT_PARAMETERS variables contain the name of the event and information the bean is sending to the form. A typical interaction that could occur includes the following steps: 1. The user clicks the bean area for a Calendar bean. This bean area has a visible component on the form that looks like a button. The label is set to the hire date for an employee. 2. The Calendar bean is invoked and displays a calendar initially set to the employee’s hire date. 3. The user changes the date on the bean by picking a new month and year, then clicking on a day, which initiates the DateChanged event. 4. The When-Custom-Item-Event trigger obtains the changed date and assigns it back to the employee hire_date item, also changing the label on the bean area “button”.

Oracle Forms Developer 10g: Build Internet Applications 16-22

Interacting with JavaBeans (continued) Coding a When-Custom-Item-Event Trigger In a When-Custom-Item-Event trigger to respond to JavaBeans events, you code the action that you want to take place when an event occurs. For example, when a user selects a date from the Calendar bean, the DateChange event takes place and the When-Custom-Item-Event trigger fires. In the code for the When-Custom-ItemEvent trigger on the Calendar bean area item, you need to obtain the name of the event. If it is the DateChange event, you must obtain the new date and assign it to a form item, such as the employee’s hire date. You can use the system variables containing the event and parameter information: declare hBeanEventDetails ParamList; eventName varchar2(80); paramType number; eventType varchar2(80); newDateVal varchar2(80); newDate date := null; begin hBeanEventDetails := get_parameter_list (:system.custom_item_event_parameters); eventName := :system.custom_item_event; if(eventName = 'DateChange') then get_parameter_attr(hBeanEventDetails, 'DateValue', ParamType, newDateVal); newDate := to_date(newDateVal,'DD.MM.YYYY'); end if; :employees.hire_date := newDate; end; The above example is for a bean that uses hand-coded integration. If you use the FBEAN package to integrate the bean, the name of the value passed back to the form is always called ‘DATA’. For example: get_parameter_attr(:system.custom_item_event_parameters, 'DATA',paramType,eventData); (where paramType and eventData are PL/SQL variables you declare in the When-CustomItem-Event trigger, like paramType and newDateVal in the preceding example). Note: There are many examples of JavaBeans in the Forms Demos that you can download from OTN: http://otn.oracle.com/sample_code/products/forms/index.html

You can import the pr16_1. 6. 2. You will not be able to test the Color button yet.txt file. 4. create a new button called Image_Button and position it on the toolbar.txt file into a trigger that fires when the Image_Button is clicked. the visible property toggles to True for both the Product Image item and the Image Description item. Hint: Most customers who have outstanding credit orders exceed the credit limits. because the bean does not function until you instantiate it in Practice 20. In the CUSTGXX form. but you will write the code to instantiate it in Practice 20. 5. if the visible property is currently False. (If you wish to see a list of customers and their outstanding credit orders.) Customer 120 has outstanding credit orders of less than $500. Save and compile the form. the visible property toggles to False for both the Product Image item and the Image Description item. The bean will not function at this point. Begin to implement a JavaBean for the ColorPicker bean area on the CONTROL block that will enable a user to choose a color from a color picker. write a trigger that fires when the credit limit changes. The trigger should display a message warning the user if a customer’s outstanding credit orders (those with an order status between 4 and 9) exceed the new credit limit. The file contains code that determines the current value of the visible property of the Product Image item. Set the Label property to Image Off.txt file.sql script in SQL*Plus. Import the pr16_6. If the current value is True. you will add code to populate the image item in Practice 20.
Oracle Forms Developer 10g: Build Internet Applications 16-28
. In the ORDGXX form CONTROL block. 7. 3. Set the following properties on the button: Label: Canvas Color Mouse Navigate: No Keyboard Navigable: No Background color: white The button should call a procedure named PickColor. Save and compile the form.Practice 16 1. Finally. so you should receive the warning for most customers. Click Run Form to run the form and test the functionality. the label changes on the Image_Button to reflect its next toggle state. Note: The image will not display in the image item at this point. so you shouldn’t receive a warning when changing this customer’s credit limit. Create a button on the CV_CUSTOMER canvas to enable the user to change the canvas color using the ColorPicker bean. with the imported text from the the pr16_3. run the CreditOrders. Click Run Form to run the form and test the functionality. However.

This is displayed as a modal window. Click MetaLink Search and search on the error number.com.
Oracle Forms Developer 10g: Build Internet Applications 17-4
. The default display is on the message line.Run-Time Messages and Alerts Overview (continued) • System alert: Alerts give information to the operator that require either an acknowledgment or an answer to a question before processing can continue. and issue to the operator for a response by using the SHOW_ALERT built-in. When more than one message is waiting to show on the message line. Instructor Note You can point out to students that the error messages can be used to look up information in MetaLink to help resolve errors. the current message also displays as an alert. such as FRM-40735. Oracle Forms. You can further refine your search by selecting the product.oracle. • Application alert: These are alerts that you design as part of your application. You can also build messages and alerts into your application: • Application message: These are messages that you build into your application by using the MESSAGE built-in. The URL for MetaLink is http://metalink.

which may itself fail.
Oracle Forms Developer 10g: Build Internet Applications 17-6
. For example.Built-Ins and Handling Errors (continued) Built-In functions for detecting success and failure Forms Builder supplies some functions that indicate whether the latest action in the form was successful. can cause a Pre-Query trigger to fire. the EXECUTE_QUERY procedure. The failing action may occur in a trigger that fired as a result of a built-in from the first trigger.
Built-In Function FORM_SUCCESS FORM_FAILURE FORM_FATAL
Description of Returned Value TRUE: Action successful FALSE: Error or fatal error occurred TRUE: A nonfatal error occurred FALSE: Either no error. or a fatal error TRUE: A fatal error occurred FALSE: Either no error. or a nonfatal error
Note: These built-in functions return success or failure of the latest action in the form.

Forms then only issues messages that are above the severity level defined in this variable. This means that messages of all severities are displayed.
Oracle Forms Developer 10g: Build Internet Applications 17-10
. you can specify that only messages above a specified severity level are to be issued by the form. The default value for MESSAGE_LEVEL (at form startup) is 0.Controlling System Messages (continued) Suppressing messages according to their severity (continued) In a trigger. You do this by assigning a value to the system variable MESSAGE_LEVEL.

. if required. by performing the assignments in a When-New-Form-Instance trigger.Example of Suppressing Messages (continued) Suppressing working messages Working messages are displayed when the Forms is busy processing an action.SUPPRESS_WORKING := ’TRUE’. You can suppress this message by setting the system variable SUPPRESS_WORKING to True: :SYSTEM.
Oracle Forms Developer 10g: Build Internet Applications 17-12
.. For example.. Note: You can set these system variables as soon as the form starts up. while querying you receive the message: Working.

customer_id. RAISE form_trigger_failure. and therefore traps the user in the Customer_ID item: SELECT cust_first_name || ‘ ‘ || cust_last_name INTO :ORDERS. EXCEPTION WHEN no_data_found THEN MESSAGE(’Customer with this ID not found’).
Oracle Forms Developer 10g: Build Internet Applications 17-14
.customer_name FROM CUSTOMERS WHERE customer_id = :ORDERS. Instructor Note The broken line in the diagram represents possible route into the EXCEPTION section if the designer has coded an exception handler for FORM_TRIGGER_FAILURE or OTHERS. It raises an exception to fail the trigger when the message is sent.The FORM_TRIGGER_FAILURE Exception (continued) Example This example adds an action to the exception handler of the When-Validate-Item trigger for the Customer_ID item.

Example of an On-Error Trigger This On-Error trigger sends a customized message for error 40202 (field must be entered).Triggers for Intercepting System Messages (continued) Remember that you can use the built-in functions ERROR_CODE. ELSE MESSAGE(ERROR_TYPE || ’-’ || TO_CHAR(ERROR_CODE) || ’: ’ || ERROR_TEXT).
Oracle Forms Developer 10g: Build Internet Applications 17-16
. IF ERROR_CODE = 40202 THEN MESSAGE(’You must fill in this field for an Order’). but reconstructs the standard system message for all other errors. ERROR_TEXT. Instructor Note Remind students that On. and ERROR_TYPE to identify the details of the error. and possibly use this information in your own message.triggers fire in place of the usual processing. END IF. RAISE FORM_TRIGGER_FAILURE.

Oracle Forms Developer 10g: Build Internet Applications 17-18
.40301) THEN MESSAGE(’No Orders found-check your search values’). If your applications must be supported in more than one national language. Example of an On-Message trigger This On-Message trigger modifies the “Query caused no records to be retrieved” message (40350) and the “Query caused no records to be retrieved. then use MESSAGE_CODE in preference to MESSAGE_TEXT when checking a message. Re-enter.On-Message Trigger (continued) Note: These functions return information about the most recent message that was issued.” message (40301):. IF MESSAGE_CODE in (40350. END IF. ELSE MESSAGE(MESSAGE_TYPE || ’-’ || TO_CHAR(MESSAGE_CODE) ||: ’|| MESSAGE_TEXT).

You handle the display and responses to an alert by using built-in subprograms. but maximum of 200 characters
Oracle Forms Developer 10g: Build Internet Applications 17-20
. How to create an alert Like other objects you create at design-time. Button2. No. • Select the Alerts node in the Navigator. and must acknowledge. and take action based on the operator’s returned response. Use alerts when you need to perform the following: • Display a message that the operator cannot ignore. alerts are created from the Object Navigator. The properties that you can specify for an alert include the following:
Property Name Title Alert Style Button1. or Note Labels for each of the three possible buttons (Null indicates that the button will not be displayed) Specifies which button is selected if user presses [Enter] Message that will appear in the alert – can be multiple lines. Button3 Labels Default Alert Button Message Description Name for this object Title that displays on alert Symbol that displays on alert: Stop. Because they display in a modal window. • Activate the alert at run time by using built-ins. and then select Create. and define its properties in the Property palette. Alerts are therefore managed in two stages: • Create the alert at design-time. or Cancel). • Ask the operator a question where up to three answers are appropriate (typically Yes. • Define the properties of the alert in the Property Palette. alerts provide an effective way of drawing attention and forcing the operator to answer the message before processing can continue. Caution.Creating and Controlling Alerts Alerts are an alternative method for communicating with the operator.

ALERT_BUTTON2.Controlling Alerts at Run Time (continued) SET_ALERT_BUTTON_PROPERTY procedure Use this built-in to change the label on one of the alert buttons: SET_ALERT_BUTTON_PROPERTY(’alert_name’.) Property The property being set. use LABEL Value The character string that defines the label
Oracle Forms Developer 10g: Build Internet Applications 17-23
. as defined in Forms Builder (You can alternatively specify an alert_id (unquoted) for this argument. button. property. ’value’)
Parameter Description Alert_name The name of the alert.) Button The number that specifies the alert button (Use ALERT_BUTTON1. and ALERT_BUTTON3 constants.

to obtain confirmation.fmb file that demonstrates creating a generic alert. then the DELETE_RECORD built-in is called to delete the current record from the block. message. Run the form.SHOW_ALERT Function (continued) Example A trigger that fires when the user attempts to delete a record might invoke the alert.
Oracle Forms Developer 10g: Build Internet Applications 17-25
. IF SHOW_ALERT(’del_check’) = ALERT_BUTTON1 THEN DELETE_RECORD. END IF. shown opposite. The button number that you clicked appears in the text item. Open the Show_Alert. Show the underlying code in this form. 2. and button labels to any value you want. Set title. 3. Click the Show the Alert button. If the operator selects Yes. Instructor Note Demonstration Write a trigger that displays your earlier alert. 1.

you must distinguish between the following two types of DML statements:
Type Implicit DML Description DML statements that are associated with base table blocks.Handling Errors Raised by the Oracle Database Server (continued) Types of DML statements Declarative-constraint violations and firing of database triggers are in turn caused by DML statements. Forms constructs and issues these DML statements. • FRM-40509: ORACLE error: unable to UPDATE record. Forms displays one of these FRM-error messages: • FRM-40508: ORACLE error: unable to INSERT record. You can obtain meaningful information about this error from the JInitiator Control Panel. Implicit DML is also called base table DML.
Oracle Forms Developer 10g: Build Internet Applications 17-28
. You can use ERROR_CODE to trap these errors in an On-Error trigger and then use DBMS_ERROR_CODE and DBMS_ERROR_TEXT to determine the ORA-error code and message. • FRM-40510: ORACLE error: unable to DELETE record. For error-handling purposes. By default.
Explicit DML
FRM-Error messages caused by implicit DML errors If an implicit DML statement causes an Oracle server error. DML statements that a developer explicitly codes in triggers or program units. FRM-Error messages with Web-deployed Forms Users may receive a generic FRM-99999 error.

Practice 17 1. Alter the When-Radio-Changed trigger on Credit_Limit to show the Credit_Limit_Alert instead of the message when a customer’s credit limit is exceeded. 2.txt.) 6. 5. Save and compile the form. Click Run Form to run the form and test the changes. 3. 4.
Oracle Forms Developer 10g: Build Internet Applications 17-34
. The message should read “This customer's current orders exceed the new credit limit”. Create a generic alert in ORDGXX called Question_Alert that allows Yes and No replies. Create an alert in CUSTGXX called Credit_Limit_Alert with one OK button. Save and compile the form. (You can import the text from pr17_4. Click Run Form to run the form and test the changes. Alter the When-Button-Pressed trigger on CONTROL.Exit_Button to use the Question_Alert to ask the operator to confirm that the form should terminate.

The query is performed. 4.Query Processing Overview (continued) 3. Forms fetches the column values of a row into the base table items of a new record in the block. Steps 4 through 7 are repeated for any remaining records of this query. this record is flushed from the block. 5. 6. If it fails. 7. 8. Forms fires the Post-Query trigger. Forms performs item and record validation if the record has changed (due to a trigger). The record is marked Valid.
Oracle Forms Developer 10g: Build Internet Applications 18-4
.

The entire WHERE clause is optional.SELECT Statements Issued During Query Processing (continued) Note: The vertical bar ( | ) in the ORDER BY clause indicates that either of the two possibilities can be present. enter one or more variables in the example record and press Count Query. If you want to count records that satisfy criteria specified in the Query/Where dialog box. The ORDER BY clause is also optional. Forms retrieves the ROWID only when the Key Mode block property is set to Unique (the default).
Oracle Forms Developer 10g: Build Internet Applications 18-6
.

however. If set to zero. because Forms fetches and displays only one record at a time.
Oracle Forms Developer 10g: Build Internet Applications 18-14
. Query All Records Property: Specifies whether all the records matching the query criteria should be fetched into the data block when a query is executed. • No: Fetches the number of records specified by the Query Array Size block property. By contrast.Query Array Processing (continued) Query Array Size Property: This property specifies the maximum number of records that Forms should fetch from the database at one time. the query array size defaults to the number of records displayed in the block. the larger size reduces overall processing time by making fewer calls to the database for records. A size of 1 provides the fastest perceived response time. • Yes: Fetches all records from query. a size of 10 fetches up to ten records before displaying any of them.

select a trigger. END IF. Instructor Note The following triggers may fire in Enter-Query mode: • Key• On-Error • On-Message • When. set the Fire in Enter-Query Mode property to Yes. perform the following steps: • In the Object Navigator.
To create a trigger that fires in Enter-Query mode. and the LOV is required to help with query criteria as well as data entry. then the When-Button-Pressed trigger should fire in both modes. This trigger has Fire in Enter-Query Mode set to Yes (default for this trigger type):
IF SHOW_LOV(’Customers’) THEN MESSAGE(’Selection successful’).triggers.Coding Triggers for Enter-Query Mode (continued) Example If you provide a button for the operator to invoke an LOV. • In the Property Palette. except: When-Database-Record When-Image-Activated When-New-Block-Instance When-New-Form-Instance When-Create-Record When-Remove-Record When-Validate-Record When-Validate-Item
Oracle Forms Developer 10g: Build Internet Applications 18-16
.

Using built-ins in Enter-Query Mode Some built-in subprograms are illegal if a trigger is executed in Enter-Query mode. UP. Otherwise. GO_RECORD.
Oracle Forms Developer 10g: Build Internet Applications 18-18
. the button executes the query (using the EXECUTE_QUERY built-in).MODE = ’NORMAL’ THEN ENTER_QUERY. If the operator clicks the button in Normal mode. if already in Enter-Query mode. NEXT_RECORD. OPEN_FORM. These include GO_BLOCK. DOWN. IF :SYSTEM. PREVIOUS_BLOCK. PREVIOUS_RECORD. One general restriction is that in Enter-Query mode you can not navigate to another record in the current form.Coding Triggers for Enter-Query Mode (continued)
Example Consider the following When-Button-Pressed trigger for the Query button. and others. So any built-in that would potentially enable this is illegal. NEXT_BLOCK. then the trigger places the form in EnterQuery mode (using the ENTER_QUERY built-in). Again. ELSE EXECUTE_QUERY. consult the Forms Builder online Help which specifies whether an individual built-in can be used in this mode. END IF.

parse. but before it fetches the records
On-Fetch
Pre-Select On-Select
Post-Select
Oracle Forms Developer 10g: Build Internet Applications 18-21
.) Fires when Forms would usually perform default Count Query processing to determine the number of rows that match the query conditions. default processing.Overriding Default Query Processing (continued) Transactional Triggers for query processing have the following characteristics:
Trigger On-Close On-Count Characteristic Fires when Forms closes a query (It augments. rather than replaces.) Fires after Forms has constructed and issued the block SELECT statement.) The trigger continues to fire until: • No queried records are created during a single execution of the trigger • The query is closed by the user or by the ABORT_QUERY built-in executed from another trigger • The trigger raises FORM_TRIGGER_FAILURE Fires after Forms has constructed the block SELECT statement based on the query conditions. but before it issues this statement Fires when Forms would usually issue the block SELECT statement (The trigger replaces the open cursor. and execute phases of a query. Fires when Forms performs a fetch for a set of rows (You can use the CREATE_QUERIED_RECORD built-in to create queried records if you want to replace default fetch processing.

Obtaining Query Information at Run Time (continued) Using GET_ITEM_PROPERTY and SET_ITEM_PROPERTY

The following item properties may be useful for getting query information. Only the properties marked with an asterisk can be set. • CASE_INSENSITIVE_QUERY (*) • QUERYABLE (*) • QUERY_ONLY (*) • QUERY_LENGTH
Instructor Note QUERYABLE determines if the item can be included in a query against the base table of the block to which the item belongs. QUERY_ONLY specifies that an item can be queried but that it should not be included in any INSERT or UPDATE statement that Forms issues for the block at run time.

Oracle Forms Developer 10g: Build Internet Applications 18-24

Summary

In this lesson, you should have learned that: • Query processing includes the following steps:
1. 2. 3. 4. 5. 6. 7. Pre-Query trigger fires SELECT statement constructed Query performed Record fetched into block Record marked Valid Post-Query trigger fires Item and record validation if the record has changed (due to a trigger) 8. Steps 4 through 7 repeat till all fetched

Summary In this lesson, you learned how to control the events associated with queries on base table blocks. • The query process: Prior to beginning the query, the Pre-Query trigger fires once for each query. Then the query statement is constructed and executed. For each record retrieved by the query, the record is fetched into the block and marked as valid, the Post-Query trigger fires for that record, and item and record validation occurs if a trigger has changed the record.

Oracle Forms Developer 10g: Build Internet Applications 18-25

Summary

•

The query triggers, which must be defined at block or form level, are:
– Pre-Query: Use to screen query conditions (set ONETIME_WHERE or DEFAULT_WHERE properties, or assign values to use as query criteria) – Post-Query: Use to supplement query results (populate nonbase table items, perform calculations)

Summary (continued) • The Pre-Query trigger fires before the query executes. This trigger is defined at the block level or above. Use the Pre-Query trigger to check or modify query conditions. • The Post-Query trigger fires as each record is fetched (except array processing). This trigger is defined at the block level or above. Use the Post-Query trigger to perform calculations and populate additional items. • Some triggers can fire in both Normal and Enter-Query modes. Use SYSTEM.MODE to test the current mode. Some built-ins are illegal in Enter-Query mode. • Override default query processing by using transactional triggers; to replace the default functionally, use “Do-the-right-thing” built-ins. • Obtain query information at run-time by using: SYSTEM.MODE, SYSTEM.LAST_QUERY Some properties of GET/SET_BLOCK_PROPERTY and GET/SET_ITEM_PROPERTY

Practice 18 Overview In this practice, you create two query triggers to populate nonbase table items. You will also change the default query interface to enable case-sensitive and exact match query. • Populating customer names and sales representative names for each row of the ORDERS block • Populating descriptions for each row of the ORDER_ITEMS block • Restricting the query on the INVENTORIES block for only the first query on that block • Disabling the effect of the Exit button and changing a radio group in Enter-Query mode • Adding two check boxes to the Customers form to enable case-sensitive and exact match query Note: For solutions to this practice, see Practice 18 in Appendix A, “Practice Solutions.”

Oracle Forms Developer 10g: Build Internet Applications 18-27

Practice 18 1. In the ORDGXX form, write a trigger that populates the Customer_Name and the Sales_Rep_Name for every row fetched by a query on the ORDERS block. You can import the text from pr18_1.txt.

2. Write a trigger that populates the Description for every row fetched by a query on the ORDER_ITEMS block. You can import the text from pr18_2.txt. 3. Change the When-Button-Pressed trigger on the Stock_Button in the CONTROL block so that users will be able to execute a second query on the INVENTORIES block that is not restricted to the current Product_ID in the ORDER_ITEMS block. You can import the text from pr18_3.txt. 4. Ensure that the Exit_Button has no effect in Enter-Query mode. 5. Click Run Form to run the form and test it. 6. Open the CUSTGXX form module. Adjust the default query interface. Add a check box called CONTROL.Case_Sensitive to the form so that the user can specify whether or not a query for a customer name should be case sensitive. Place the check box on the Name page of the TAB_CUSTOMER canvas. You can import the pr18_6.txt file into the When-Checkbox-Changed trigger. Set the initial value property to Y, and the Checked/Unchecked properties to Y and N. Set the Mouse Navigate property to No. 7. Add a check box called CONTROL.Exact_Match to the form so that the user can specify whether or not a query condition for a customer name should exactly match the table value. (If a nonexact match is allowed, the search value can be part of the table value.) Set the label to: Exact match on query? Set the initial value property to Y, and the Checked/Unchecked properties to Y and N. Set the Mouse Navigate property to No. You can import the pr18_7.txt file into the Pre-Query Trigger. 8. Ensure that the When-Radio-Changed trigger for the Credit_Limit item does not fire when in Enter-Query mode. 9. Click Run Form to run the form and test the changes.

After completing this lesson, you should be able to do the following: • Explain the effects of the validation unit upon a form • Control validation:
– Using object properties – Using triggers – Using Pluggable Java Components

• •

Describe how Forms tracks validation status Control when validation occurs

the above checks are postponed until navigation moves out of that unit. or form level). • The application runs on the Internet and you want to improve performance by reducing round trips to the application server. You might set a validation unit above item level under one of the following conditions: • Validation involves database references. including the firing of When-Validate-Item and When-Validate-Record triggers. block.Using Object Properties to Control Validation (continued) At higher validation units (record. You may want to set Validation Unit to a higher level. and demonstrate its effect at run time. Instructor Note Show the Validation Unit property in Forms Builder. and you want to postpone traffic until the operator has completed a record (record level).
Oracle Forms Developer 10g: Build Internet Applications 19-6
. All outstanding items and records are validated together.

You also need to define the Return Item for the LOV column as the item being validated. Then. build and run the form to show the use of this feature.Using LOVs for Validation (continued) Note: Make sure that LOVs you create for validation purposes have the validation column defined first. For performance reasons. with a display width greater than 0. do not use the LOV for Validation property for large LOVs. Instructor Note Set the Validate from List property on an item to which you have already attached a suitable LOV.
Oracle Forms Developer 10g: Build Internet Applications 19-8
.

Order status of 4 is new credit order IF :orders.Controlling Validation by Using Triggers (continued) When-Validate-Record Trigger This trigger fires after standard record-level validation. and it can fire on population at query time.3) sometimes ask about using Post-Change as a validation trigger. Instructor Note Introduce When-Validate-Record as an additional validation trigger. IF :control. BEGIN -.order_status = 4 THEN SELECT credit_limit INTO cred_limit FROM customers WHERE customer_id = :orders. Example This When-Validate-Record trigger on block ORDER_ITEMS warns the operator when a line item for a new credit order causes the customer’s credit limit to be exceeded. In the example above. END IF.
Oracle Forms Developer 10g: Build Internet Applications 19-10
. END.total > cred_limit THEN n := show_alert('credit_limit_alert').customer_id. you would include this code immediately after displaying the alert. Because Forms has already checked that required items for the record are valid. Its use is not recommended in new applications. Students who have experience with early versions of the product (SQL*Forms V2. in the order they were entered. you can use this trigger to perform additional checks that may involve more than one of the record’s items. you can raise an exception to fail the trigger: RAISE form_trigger_failure. DECLARE cred_limit number. n number. When-Validate-Record must be defined at block level or above. END IF. when the operator has left a new or changed record. Note: If you want to stop the operator from navigating out of the item when validation fails. making it less specific to validation than the When-Validate-<object> triggers. The Post-Change trigger is included only for compatibility with previous versions of Forms Builder. Post-Change does not fire if an item is set to Null.

as above. the NO_DATA_FOUND exception is raised. Note: A failing When-Validate-Item trigger prevents the cursor from leaving the item.Controlling Validation by Using Triggers (continued) Example: Validating user input (continued) If the Customer_ID item contains a value that is not found in the table. and the trigger will fail because there is no exception handler to prevent the exception from propagating to the end of the trigger. the user receives the message: FRM-40735: <trigger type> trigger raised unhandled exception <exception>
Oracle Forms Developer 10g: Build Internet Applications 19-12
. For an unhandled exception.

the two terms are often used interchangeably. Although both are Java components that you can use in a form.
Oracle Forms Developer 10g: Build Internet Applications 19-14
. there are the following differences between them: • JavaBeans are implemented in a bean area item. and in fact. whereas PJCs are implemented in a native Forms item such as a text item or check box.Using Client-Side Validation (continued) Pluggable Java Components are similar to JavaBeans. but JavaBeans may be registered at run time with the FBean package. • PJCs must always have the implementation class specified in the Property Palette.

or by the When-CreateRecord trigger. Whenever an item in a record is marked as changed. • If validation of the item has been successful • After successful post or commit • Each item in a duplicated record inherits the status of its source. Forms marks an item as changed under the following conditions: • When the item is changed by the user or a trigger • When any item in a new record is changed. Forms marks that record as new.
CHANGED
VALID
Record Validation Status
Status NEW Definition When a record is created. or by the When-Create-Record trigger. This is true even if the item is populated by the Copy Value from Item or Initial Value item properties.Tracking Validation Status (continued) Item Validation Status
Status NEW Definition When a record is created. all of the items in the record are marked as changed. Forms marks a record as valid under the following conditions: • After all items in the record have been successfully validated • All records that are fetched from the database are marked as valid • After successful post or commit • A duplicate record inherits the status of its source
CHANGED VALID
Oracle Forms Developer 10g: Build Internet Applications 19-17
. Forms marks that record as changed. This is true even if the item is populated by the Copy Value from Item or Initial Value item properties. Forms marks an item as valid under the following conditions: • All items in the record that are fetched from the database are marked as valid. Forms marks every item in that record as new.

VALIDATE VALIDATE(scope)forces Forms to immediately execute validation processing for the indicated scope. or ITEM_SCOPE.
Oracle Forms Developer 10g: Build Internet Applications 19-19
. and you need to bypass normal validation.Controlling When Validation Occurs with Built-Ins (continued) SET_FORM_PROPERTY You can use this to disable Forms validation. Set the Validation property to Property_False for this purpose: SET_FORM_PROPERTY(’form_name’. BLOCK_SCOPE. PROPERTY_FALSE). For example. You can also use this built-in to change the validation unit programmatically: SET_FORM_PROPERTY(’form_name’. RECORD_SCOPE.VALIDATION. Note: Scope is one of DEFAULT_SCOPE. scope). suppose you are testing a form.VALIDATION_UNIT.

6. 3. In the ORDGXX form.txt.txt. Perform client-side validation on the ORDER_ITEMS. 2. You will set the filter for the item in the next practice.forms. You can import text from pr19_4a. Click Run Form to run the form and test the functionality.Quantity item using a Pluggable Java Component to filter the keystrokes and allow only numeric values. Fail the trigger if the data is not found. and write them to the Description item and the Price item.Product_Id to derive the name of the product and suggested wholesale price. create a trigger to write the correct values to the Customer_Name. 5. to be used as the Implementation Class for the item. write a validation trigger to check that if the Order_Mode is online.txt and pr19_4b. the Order_Status indicates a CREDIT order (values between 4 and 10). Sales_Rep_Name. 4. Save and compile the form. Do not test the validation on the Quantity item because it will not function until after you set the filter on the item in Practice 20. cause the Account_Mgr_Lov to be displayed whenever the user enters an Account_Mgr_Id that does not exist in the database. In the ORDGXX form. Fail the trigger and display a message if the product is not found.Practice 19 1.
Oracle Forms Developer 10g: Build Internet Applications 19-23
. 7. Click Run Form to run the form and test the changes. In the CUSTGXX form.demos. Save and compile the form. You can import the text from pr19_3. and Sales_Rep_Id items whenever validation occurs on Customer_Id.txt. so the validation is not yet functional. You can import the text from pr19_5. The full path to the PJC class is oracle. Create another validation trigger on ORDER_ITEMS.KeyFilter (this is case sensitive).

Oracle Forms Developer 10g: Build Internet Applications 20-4
. The Cursor and how it Relates to the Navigation Unit The cursor is a visible. If Forms cannot move the navigation unit back to its initial location. external object that indicates the current input focus. Note that the cursor is still at its initial position.Navigation Overview (continued) Entering and Leaving Objects During navigation. In this sense. it exits the form. Forms leaves and enters objects. Leaving an object means changing the navigation unit to the object above. Forms reverses the navigation path and attempts to move the navigation unit back to its initial location. the navigation unit acts as a probe. Forms will not move the cursor until the navigation unit has successfully become the target item. What Happens if Navigation Fails? If navigation fails. Entering an object means changing the navigation unit from the object above in the hierarchy.

Oracle Forms Developer 10g: Build Internet Applications 20-6
.Understanding Internal Navigation (continued) Example When you commit your inserts. internally the following navigation events must occur before commit processing begins: • Exit current item • Exit current record • Exit current block Performance Note Forms uses smart event bundling: All the events that are triggered by navigation between two objects are delivered as one packet to Forms Services on the middle tier for subsequent processing. updates. you do not see the input focus moving. Instructor Note Draw navigation examples of “on entry” and “on commit. which displays messages as navigational triggers fire.”
Demonstration: Run the form Navdemo. and deletes to the database. This illustrates the navigation that occurs behind the scenes when a form first opens. However.fmx.

jar in WinZip.1.class is oracle\forms\demos\beans.beans.forms.colorpicker'.
At run time.Colorpicker bean area item when the CUSTOMERS form is run by including the following code in your When-New-FormInstance trigger:
FBean.demos.Register_Bean('control.Initializing Forms Builder Objects (continued) Example Register the Color Picker JavaBean into the Control.ColorPicker').
Oracle Forms Developer 10g: Build Internet Applications 20-14
. Forms looks for the Java class contained on the middle tier or in the archive files with the path specified in the code. you find that the path to ColorPicker. If you open colorpicker. 'oracle.

and Post-Triggers (continued)
Trigger Type Pre-Form Use to Validate − User − Time of day Initialize control blocks • • Call another form to display messages • Perform housekeeping.Using the Pre. such as erasing global variables • Display messages to user before exit • Authorize access to the block • Set global variables • Validate the last record that had input focus • Test a condition and prevent the user from leaving the block • Set global variables Clear global variables • • Set a visual attribute for an item as the user scrolls through a set of records Perform cross field validation • • Derive a complex default value Record the previous value of a text item • • Calculate or change item values
•
Post-Form
Pre-Block Post-Block
Pre-Record Post-Record
Pre-Text-Item Post-Text-Item
Oracle Forms Developer 10g: Build Internet Applications 20-16
.

When the ORDGXX form first opens.Product_Image item and the CV_ORDER canvas to the same value. set a filter on the ORDER_ITEMS. Is there another trigger where you might also want to place this code? 5. You can import the code for the procedure from pr20_2a. Click Run Form to run the form again and test the changes. Write a trigger that fires as the cursor arrives in each record of the ORDER_ITEMS block to populate the Product_Image item with a picture of the product. First create a procedure called get_image to populate the image. You can import the code from pr20_9. and click Run Form to run the form and test the Color button. Define the same trigger type and code on the ORDERS block. 10.
Oracle Forms Developer 10g: Build Internet Applications 20-24
.txt.txt. The image item has a lot of blank space when the image does not take up the entire area. compile. register the ColorPicker bean (making its methods available to Forms) when the form first opens. In the CUSTGXX form.txt. Notice that you receive an error if the image file does not exist. Click Run Form to run the form and test the changes. Save and compile the form. 3. Set the Bevel for the Product_Image item to None. such as r0g75b75.Practice 20 1. Code a trigger to gracefully handle the error by populating the image item with a default image called blank. 2.Quantity Pluggable Java Component. if one exists. You can import the code from pr20_6. You should be able to invoke the ColorPicker bean from the Color button. 7. 8. and execute a query.txt. and also execute a query on the CUSTOMERS block.jpg. 9. set its Background Color of both the CONTROL. You can import the code for the trigger from pr20_1. then call that procedure from the appropriate trigger. 4. To make it look better. now that the bean has been registered at form startup. Save. 6.

If encountered in a Forms program unit. but certain built-ins. The user can then attempt to correct the error before trying to save again. or when a transactional trigger fails. and a failing insert or update results in the record being redisplayed. and will roll back to the latest savepoint if certain events occur. can request a rollback to the latest savepoint by using the TO_SAVEPOINT option. Forms treats COMMIT as the COMMIT_FORM built-in. savepoints. Generally. the user is informed of the error through a message. and locking. Savepoints Forms issues savepoints in a transaction automatically.
Oracle Forms Developer 10g: Build Internet Applications 21-5
.Transaction Processing Overview (continued) Other events related to transactions include rollbacks. database locks are automatically applied. ROLLBACK. Locks also apply during the posting phase of a transaction. Locking When you update or delete base table records in a form application. Rollbacks Forms will roll back applied changes to a savepoint if an error occurs in its default processing. and SAVEPOINT cannot be called from a trigger directly. such as the EXIT_FORM built-in procedure. and ROLLBACK as the CLEAR_FORM built-in. Note: The SQL statements COMMIT. these savepoints are for Forms internal use. By default. and for DML statements that you explicitly use in your code.

The user receives the message “Transaction Completed. thus discarding the rollback data. By default. the row is locked on the base table. After the user queries the record.”. to make sure the new price is not lower than the existing one. because the update has already been applied. The user saves the change. releasing locks.
Oracle Forms Developer 10g: Build Internet Applications 21-13
. The Pre-Update trigger fires (if present). the Oracle database retains the old column value as rollback data. It is too late to compare the item against the column. At this stage. However.. The Post-Update trigger fires (if present). The user updates the Price item. 3. Forms applies the user’s change to the database row. 5.Life of an Update (continued) Example The price of a product is being updated in a form. The trigger could compare the two values. so that a failure of this trigger reinstates the original value. 2. 6. and making the changes permanent. This is now different from the corresponding database column.. initiating the transaction process. The item and column are now the same. Forms issues the database commit. because the update has not been applied to the base table. 4. for example. the item and column are still different. the following events occur: 1.

dummy.customer_id.
DECLARE CURSOR C1 IS SELECT ’anything’ FROM ORDERS WHERE customer_id = :CUSTOMERS. a PL/SQL variable ceases to exist. BEGIN OPEN C1.
Oracle Forms Developer 10g: Build Internet Applications 21-15
. END. RAISE form_trigger_failure. IF C1%FOUND THEN CLOSE C1.Delete Validation (continued) Example This Pre-Delete trigger on the CUSTOMER block of the CUSTOMERS form prevents deletion of rows if there are existing orders for the customer. ELSE CLOSE C1. END IF. A global variable exists for the session. When the block terminates.
Instructor Note In the preceding example. FETCH C1 INTO :GLOBAL. a local PL/SQL variable could be used rather than a global variable. MESSAGE(’There are orders for this customer!’).

order_id FROM SYS. You can also assign sequence numbers from a table. • Generate and run to show effects.order_id should be No.dual.nextval INTO :ORDERS. so that the user does not enter an ID manually. recording the new upper value for the sequence. which will be written to the ORDER_ID column when the row is subsequently inserted.
Oracle Forms Developer 10g: Build Internet Applications 21-17
. in the ORDERS block.
SELECT ORDERS_SEQ. Instructor Note Demonstration In the demonstration form that you are building: • Create the Pre-Insert trigger. • Use Post-Insert to update the sequence table.Assigning Sequence Numbers to Records (continued) Example This Pre-Insert trigger on the ORDERS block assigns an Order ID from the sequence ORDERS_SEQ. If you use this method. then two transactional triggers are usually involved: • Use Pre-Insert to select the next available number from the sequence table (locking the row to prevent other users from selecting the same value) and increment the value by the required amount.
Note: The Insert Allowed and Keyboard Navigable properties on :ORDERS. noting that the assigned sequence number appears when the new record is saved. shown above.

see below. but that none of its items have been changed yet (The record may have been populated by default values.)
INSERT
QUERY CHANGED
The three values of SYSTEM.) Indicates that one or more of the items in a newly created record have been changed (The record will be processed as an insert during the next commit process if its block has the CHANGED status.BLOCK_STATUS Value NEW Description Indicates that all records of the block have the status NEW (Note that a base table block with the status NEW may also contain records with the status INSERT caused by changing control items.)
QUERY
CHANGED
The three values of SYSTEM.) Indicates that the record corresponds to a row in the database. the record status also becomes INSERT.Getting and Setting the Commit Status (continued) The four values of SYSTEM.) Indicates that all records of the block have the status QUERY if the block is a base table block (A control block has the status QUERY if it contains at least one record with the status INSERT.) Indicates that the block contains at least one record with the status INSERT or CHANGED if the block is a base table block (The block will be processed during the next commit process. Note that a control block cannot have the status CHANGED. but that none of its base table items have been changed Indicates that one or more base table items in a database record have been changed (The record will be processed as an update (or delete) during the next commit process.FORM_STATUS
Value NEW QUERY Description Indicates that all blocks of the form have the status NEW Indicates that at least one block of the form has status QUERY and all other blocks have the status NEW CHANGED Indicates that at least one block of the form has the status CHANGED
Oracle Forms Developer 10g: Build Internet Applications 21-28
.RECORD_STATUS
Value NEW Description Indicates that the record has been created. Note that when you change a control item of a NEW record.

set the Enabled property for the Order_ID item to No. 3.UPDATE. You can import the code from pr21_7b. Import the pr21_7a.txt. You need to write Post-Insert.txt file. The better solution is to keep the total number of rows in another table that you can lock. Create three global variables called GLOBAL. Call the procedure when a message occurs. 5. This procedure uses the three global variables to display a customized commit message and then erases the global variables. To ensure that the data remains visible. but this solution is too advanced at this stage. Set the Required property for the Order_ID item to No.Practice 21 1. Save and compile the form.txt file. The first one is a message number. write a transactional trigger on the ORDERS block that populates ORDERS. Click Run Form to run the form and test the changes. 8. These variables indicate respectively the number of inserts. You can import the code from pr21_4. and run the form to test. and GLOBAL. 7. Pass the message code and a message to be displayed. Write an On-Logon trigger to control the number of connection tries.ORDER_ID. set the Background Property to gray. This procedure receives two arguments. GLOBAL. 6. Create a similar trigger on the ORDER_ITEMS block that assigns the Line_Item_Id when a new record is saved. 2.txt.DELETE. Create a procedure called HANDLE_MESSAGE. Click Run Form to run the form and test the changes. updates. 9. and deletes. In the ORDGXX form. You can import the code from pr21_1. Call the procedure when an error occurs.txt. Instructor Note Solution 21-4 is not the safest way. You can import the code from pr21_7c. and Post-Delete triggers to initialize and increment the value of each global variable.
Oracle Forms Developer 10g: Build Internet Applications 21-39
.Order_Id with the next value from the ORDERS_SEQ sequence. Open the CUSTGXX form module. Set the properties for the item as you did on ORDERS. compile.txt. Post-Update. Save. 4. and the second is a Boolean error indicator. Use the LOGON_SCREEN built-in to simulate the default login screen and LOGON to connect to the database. Pass the error code and an error message to be displayed. You can import the pr21_8.INSERT. In the ORDERS block.

Using Object IDs Outside the Initial PL/SQL Block (continued) You can pass the global variable around within the application. GO_ITEM(item_var). BEGIN item_var. To be able to reuse the object ID.
Oracle Forms Developer 10g: Build Internet Applications 22-16
. you need to convert it back to its original data type.item). END. Example The following example shows the conversion of the global variable back to its original PL/SQL variable data type:
DECLARE item_var item.id := TO_NUMBER(:GLOBAL.

You may import the code for the trigger from pr22_3. and place it just under the Color button on the CV_CUSTOMER canvas. it should navigate back to the block and item where the cursor was located when the trigger began to fire. Be sure to set the Mouse Navigate property of the button to No. It should then loop through the remaining navigable blocks of the form and print a message giving the names (SYSTEM. Label the button Show Blocks. in the CONTROL block. 3.Practice 22 1. so it will work with any form. Declare variables for these IDs.txt. and use them in each item reference in the trigger. alter the code called by the triggers that populate the Product_Image item when the image item is displayed.txt. The code is contained in pr22_1. Create a button called Blocks_Button in the CONTROL block and place it on the Toolbar canvas.current_block) of all the navigable blocks in the form. 4.
Oracle Forms Developer 10g: Build Internet Applications 22-23
. Alter the When-Button-Pressed trigger on the Image_Button so that object IDs are used. The code is contained in pr22_2. and run the form to test these features. 5.txt. 2. Add a test in the code to check Product_Image. Use the GET_ITEM_PROPERTY built-in function. The code for the button should print a message showing what block the user is currently in. Perform the trigger actions only if the image is currently displayed. Finally. Set its navigation and color properties the same as the other toolbar buttons. labeled Show Blocks. Save. Use a FIND_object function to obtain the IDs of each item referenced by the trigger. Drag the When-Button-Pressed trigger you created for the Blocks_Button of the ORDGXX form to the Blocks_Button of the CUSTGXX form. Run the CUSTGXX form to test the button. The trigger code above is generic. In the ORDGXX form. Open the CUSTGXX form and define a similar Blocks_Button.CURSOR_ITEM).CURSOR_BLOCK and :SYSTEM. compile. It should keep track of the block and item where the cursor was located when the trigger was invoked (:SYSTEM.

Benefits of Reusable Objects and Code (continued) • Improved application performance: When Forms Services communicates the user interface to the Forms Client, it sends meta-data about the items on the form. This meta-data includes values of properties that differ from the default. Once an item is defined, the meta-data about the next item includes only those properties that differ from the previous item. This is referred to as message diffing. Promoting similarities among items by using the methods of object reuse presented in this lesson improves the efficiency of message diffing and thus decreases network traffic and increases performance. Promoting Similarities Among Objects One of the easiest ways a developer can increase the efficiency of network performance through message diffing is by using consistent standards for all objects within an application. Items of different types should at least have common values for common or shared properties. To maximize reuse, the developer should apply the following guidelines in the order shown: • Accept default properties as much as possible: If the properties are not overwritten for each object, then the value for common properties will be the same regardless of the the object type, except for position and size. • Use SmartClasses to describe an object: If, because of design standards, the use of default properties is not a viable option, then the subclassing of objects from a set of SmartClasses ensures that the development standards are being met. It also forces a high degree of property sharing across widgets. Items of the same type will then have (unless overridden) the same properties and hence will be able to share properties more effectively. You will earn about SmartClasses in this lesson. • Use sets of visual attributes: If SmartClasses are not being used to enforce standards and common properties then use sets of partial visual attributes to enforce a common set of properties across objects of different types: for example, font, font size, foreground color, background color, and so on. These sets of visual attributes can be defined as Property Classes, as explained in the following slides.

Property Class What is a Property Class? A property class is a named object that contains a list of properties and their settings. Why use Property Classes? Use property classes to: • Increase productivity by setting standard or frequently used values for common properties and associating them with several Forms Builder objects. You can use property classes to define standard properties not just for one particular object, but for several at a time. This results in increased productivity, because it eliminates the time spent on setting identical properties for several objects. • Improve network performance by increasing the efficiency of message diffing.

Creating a Property Class When you create a property class, you have all the properties from every Forms Builder object available. You choose the properties and their values to include in the property class. You can create a property class in two ways: • Using the Create button in the Object Navigator • Using the Create Property Class button How to Create a Property Class from the Object Navigator 1. Click the Property Class node. 2. Click Create. A new property class entry displays. 3. Add the required properties and their values using the Add Property button in the Property Palette. How to Create a Property Class from the Property Palette 1. In the Object Navigator, click the object whose properties you want to copy into a property class. 2. Move to the Property Palette, select the properties you want to copy into a property class, and click the Property Class icon. An information alert is displayed. 3. Use the Object Navigator to locate the property class and change its name.

Oracle Forms Developer 10g: Build Internet Applications 23-6

Creating a Property Class (continued) Adding a Property Once you create a property class, you can add a property by clicking the Add Property button and selecting a property from the list. Set the value for that property using the Property Palette. You can also use the Copy Properties button and the Paste Properties button to add several properties at a time to a property class. Deleting a Property You can remove properties from a property class using the Delete Property button. Instructor Note • Create a property class in the Property Palette. • Create a property class in the Object Navigator. • Include properties for different objects. • Associate a property class with an object.

Inheriting from a Property Class Once you create a property class and add properties, you can use the property class. To apply the properties from a property class to an object, use the Subclass Information property in the Property Palette. What is an Inherited Property? An inherited property is one that takes its value from the property class that you associated with the object. An inherited property is displayed with an arrow to the left of the property name. What is a Variant Property? A variant property is one that has a modified value even though it is inherited from the property class associated with the object. You can override the setting of any inherited property to make that property variant. Variant properties are displayed with a red cross over an arrow.

Inheriting from a Property Class (continued) How to Inherit Property Values from a Property Class 1. Click the object to which you want to apply the properties from the property class. 2. Click the Subclass Information property in the Property Palette. 3. Select the property class whose properties you want to use. The object takes on the values of that property class. Inherited properties are displayed with an arrow symbol. Converting an Inherited Property to a Variant Property To convert an inherited property to a variant property, simply enter a new value over the inherited one. Converting a Variant Property to an Inherited Property To convert a variant property to an inherited property, click the Inherit icon in the Property Palette. Converting a Changed Property to a Default Property You can also use the Inherit icon to revert a changed property back to its default.

What Are Object Groups? An object group is a logical container for a set of Forms Builder objects. Why Use Object Groups? You define an object group when you want to: • Package related objects for copying or subclassing in another module • Bundle numerous objects into higher-level building blocks that you can use again in another application. Example Your application can include an appointment scheduler that you want to make available to other applications. You can package the various objects in an object group and copy the entire bundle in one operation.

You can see whether an object is local to the form document or foreign to it. • Deleting an object from a module automatically deletes the object from the object group. • Deleting an object group from a module does not delete the objects it contains from the module. • Point out that the objects in the object group are still visible in their respective positions in the Object Navigator. the Module field shows the module from which the object originates. canvas-view. If the object is foreign to the current form. The original object name is shown in the Object Name field. • It is not possible to include another object group. the item-level triggers. Subclass Information Dialog Box The Subclass Information property of a form object shows a dialog box that provides information about the origins of the object. the block-level triggers and the relations. and form-level trigger. • Drag the object group and drop it into a second form module. • Include a block. Instructor Note • Create an object group.Creating and Using Object Groups (continued) Things to consider when using object groups • Including a block in an object group also includes its items. You cannot use any of these objects in an object group without the block.
Oracle Forms Developer 10g: Build Internet Applications 23-12
.

copied. Width. Return to subclassed.
Property Palette Icon Circle Square Arrow Arrow with red X Meaning The value for the property is the default.fmb. Drag and drop the block into copied. Ability to Inherit Changes When you change the properties of a parent object. not the original height of 20. but not to copied. all child objects inherit those properties if they are not already overridden.fmb. However. Demonstrate that the change is propagated to subclassed. you can make an exact copy and then alter the properties of some objects. Select the Height property and click the Inherit icon. Change the item’s Width in referenced. The referenced. any properties that you override remain overridden. The value for the property was inherited but overridden (variant property).fmb and subclassed.fmb. If you change the parent class. The value for the property was inherited.fmb. and Height properties are all set to 20. the changes also apply to the properties of the subclassed object that you have not altered. As you make changes in properties in this demo. Open the Property Palette for that item and show that the X Position. you can click the Inherit icon to re-inherit the property from the parent object.
Instructor Note Demonstration: Open the following forms: referenced. and subclassed. copying it in the first case and subclassing it in the second.fmb module contains a block with a single item. change the Height property of the item to 40. point out the different icons for inherited and overridden properties. The value for the property was changed from the default. if the parent and child objects are in the same form • When you reload the form containing a child object Ability to re-inherit If you make changes to the child object to override properties of the parent object.fmb.fmb. The child inherits changes: • Immediately. you can add additional items to the end of a subclassed block.Subclassing an Object (continued) Ability to add to an Object You can create an exact copy of an object.fmb. In subclassed.fmb. and you can add to the subclassed object. Y Position.
Oracle Forms Developer 10g: Build Internet Applications 23-15
.fmb. Property Palette icons: Enable you to identify inherited or overridden properties.fmb to 10.fmb and show that the overridden Height of 40 is still in effect. Now change the Height property of the item in referenced. Ability to Alter Properties With subclassing. For example. Point out to students that the new Height of 10 is inherited from referenced.

Oracle Forms Developer 10g: Build Internet Applications 23-17
. for example. The smallest unit accepted in an object group is a block. iconic buttons.What Are Object Libraries? (continued) Why Object Libraries Instead of Object Groups? • Object libraries are external to the form. • Object libraries can contain individual items. • Object libraries accept PL/SQL program units. all forms that contain the subclassed object reflect the change. • If you change an object in an object library. so are easily shared among form modules.

using drag and drop in the Object Navigator • Creating a library module • Moving the program unit to an object library
Oracle Forms Developer 10g: Build Internet Applications 23-23
.Reusing PL/SQL (continued) You can reuse PL/SQL program units by: • Copying and pasting. using the Edit menu • Copying or subclassing to another form module.

PLX Files The library . If two program units of the same name and type occur in different libraries in the attachment list.Referencing Attached Library Program Units (continued) When Several Libraries are Attached You can attach several libraries to the same Oracle Forms Developer module. Example The following command creates a run-time library named runlib1. without any source. References are resolved by searching through libraries in the order in which they occur in the attachment list.
Oracle Forms Developer 10g: Build Internet Applications 23-29
. you will probably want to generate a version of your library that contains only the compiled p-code. since it is located first.PLX file is a platform-specific executable that contains no source. the one in the “higher” library will be executed.pll:
GENERATE LIB mylib FILE runlib1. You can generate a . When you are ready to deploy your application.PLX file from Forms Builder or from the command line.plx based on the open library mylib. Creating .

Include the following properties and settings: Font Name: Arial Format Mask: 99. Correct the error. set the Calculation Mode and Summary Function properties to None.fmb. Show_Help_Button. Save. Set the Window property to WINDOW1 for the Toolbar canvas. create a property class called ClassA. Apply ClassA to CV_INVENTORY and the Quantity_on_Hand item. and WIN_INVENTORY window. Total. In the ORDGXX form. Set the Canvas property for the following items to NULL: Image_Button. Set the Horizontal Toolbar Canvas property to TOOLBAR for the window. Use the Form layout style. Product_Lov_Button. including all columns except DN. and run the form again. CV_INVENTORY canvas. Product_Image. the DEPARTMENTS block must precede the CONTROL block in the Object Navigator Some items are not applicable to this form. Add the CONTROL block. 8. Set the code for the When-Button-Pressed triggers for the above buttons to: NULL. Create a new form module and copy the Stock_Objects object group into it. Create an object library and name it summit_olb. and run the form and note the error. compile.. and select to subclass the objects. For the Total item. Save the form module as STOCKXX. For proper behavior. CONTROL block. 4. Create two tabs in the object library called Personal and Corporate. and Question_Alert from the object library into the new form. consisting of the INVENTORIES block. The code of some of the triggers does not apply to this form. Create a new form. Save the form. Drag the Toolbar canvas. 9. called Stock_Objects. 2. and create a data block based on the DEPARTMENTS table.olb.Practice 23 1. 7.
Oracle Forms Developer 10g: Build Internet Applications 23-33
. Use Toolbar as the Horizontal Toolbar canvas for this form. Stock_Button. 6. and the Question_Alert from the Orders form to the Personal tab of the object library.999 Font Size: 8 Justification: Right Delete Allowed: No Background Color: DarkRed Foreground Color: Gray 5. create an object group. compile. In the new form module. the Toolbar. and set the Summarized Block property to Null. Hide_Help_Button. 3. Save the object library as summit.

Create a new form and a new data block in the form. 11. Drag these items to the Corporate tab of your object library. Change the Exit button of the Object Library’s CONTROL block to have a gray background. Create a sample date field. Place the Toolbar canvas in the new form. then run the form to test the changes. Move the similar code to PL/SQL program units and call the program units from the triggers. 13. by means of width. Create two sample buttons. Apply these SmartClasses in your form. In the Orders form. compile. Mark these items as SmartClasses. Set the width and the format mask to your preferred standard.Practice 23 (continued) 10.Customer_Id and Orders.Sales_Rep_Id items. and run the form to test it.
Oracle Forms Developer 10g: Build Internet Applications 23-34
. one for wide buttons and one for medium buttons. Try to delete items on the Null canvas. note the similarity of the code in the Post-Query trigger of the Orders block and in the When-Validate-Item triggers of the Orders. Save this form as DEPTGXX. 14. What happens and why? 12. Run the Departments form again to see that the Exit button is now gray.

these built-ins execute on the application server machine.Benefits of the WebUtil Utility (continued) What Functionality Is Available with WebUtil? There is a wealth of functionality available in the utility. but are provided as an easy way to migrate code that uses d2kwutil.
Oracle Forms Developer 10g: Build Internet Applications 24-5
. WebUtil_ClientInfo Package: Contains the following functions to obtain information about the client machine:
Function Returns: Date and time on client machine Character used on client as file separator (“\” on Windows) GET_HOST_NAME Name of client machine GET_IP_ADDRESS IP address of client (string) GET_JAVA_VERSION JVM version that is running the Forms applet GET_LANGUAGE Language code of the client machine. read or write an image to or from the client. and GET_WORKING_DIRECTORY GET_WINDOWS_USERNAME READ_INI_FILE and WRITE_INI_FILE READ_REGISTRY. and WRITE_REGISTRYEX
•
Note: Some of these may duplicate other WebUtil functions. WRITE_REGISTRY. get information about the client machine. such as de for German GET_OPERATING_SYSTEM Name of OS running the browser
GET_DATE_TIME GET_FILE_SEPARATOR
Instructor Note The many functions of WebUtil are listed here just to give students an idea of the capability of the utility.) • Client-server added value functions (ported from d2kwutil. a client-server package):
CREATE_REGISTRY_KEY and DELETE_REGISTRY_KEY GET_COMPUTER_NAME GET_NET_CONNECTION GET_TEMP_DIRECTORY. or perform HOST and TEXT_IO commands and OLE automation on the client (without the WebUtil functions. Public functions: The core of WebUtil is a set of packages. The client parity APIs are covered in more detail later in this lesson. Do not cover them in detail. GET_WINDOWS_DIRECTORY. including the following: • Client-server parity APIs that enable you to retrieve a file name from the client. each of which provides an API to implement certain functionality.

” on Windows) Any Java system propery Time zone of client machine Name of user logged in to the client
WebUtil_C_API Package: Contains the following functions to call into C libraries on the client:
Function
IsSupported RegisterFunction DeregisterFunction Create_Parameter_List Destroy_Parameter_List Add_Parameter Get_Parameter_Number Get_Parameter_Ptr Get_Parameter_String Rebind_Parameter Invoke_* Parameter_List_Count Function_Count Id_Null
Purpose: Returns True if the client is a valid platform Returns a handle to a specified C library function Deregisters function and frees client resources Creates a parameter list to pass to C function Deletes a parameter list and frees its resources Adds a parameter to the parameter list Typed functions to return parameter values Change parameter values of the existing parameter list to reuse it Typed functions to execute a registered C function Returns the number of parameter lists that have been created Returns the number of functions that have been registered Checks to see whether the various types used in the package are null
Oracle Forms Developer 10g: Build Internet Applications 24-6
.Benefits of the WebUtil Utility (continued)
Function
GET_PATH_SEPARATOR
GET_SYSTEM_PROPERTY GET_TIME_ZONE GET_USER_NAME
Returns: Character used on client to separate directory locations on paths (“.

Benefits of the WebUtil Utility (continued) WebUtil_File Package: Contains a new type called FILE_LIST. also contains the following APIs to manipulate files and directories on the client and to display file selection dialog boxes:
Function
COPY_FILE RENAME_FILE DELETE_FILE CREATE_DIRECTORY
Purpose: Copy. rename. which is a PL/SQL table used to pass back multiple file names.” on Windows)
DIRECTORY_ROOT_LIST
DIRECTORY_FILTERED_LIST FILE_EXISTS FILE_IS_DIRECTORY FILE_IS_HIDDEN FILE_IS_READABLE FILE_IS_WRITABLE DIRECTORY_SELECTION _DIALOG FILE_SELECTION_DIALOG
FILE_MULTI_SELECTION _DIALOG
GET_FILE_SEPARATOR
GET_PATH_SEPARATOR
Oracle Forms Developer 10g: Build Internet Applications 24-7
. or delete a file and return a Boolean value to indicate success Creates the named directory if it does not exist. returns a Boolean value to indicate success Returns a FILE_LIST containing the directory roots on the client system (the drives on Windows) Returns a list of files in a directory that you filter using wildcard characters (* and ?) Returns a Boolean value indicating the existence of the specified file on the client Returns a Boolean value indicating whether the specified file is a directory Returns a Boolean value indicating whether the specified file has its hidden attribute set Returns a Boolean value indicating whether the file can be read or written to Displays a directory selection dialog and returns the selected directory Enables definition of File Save or File Open dialog with configurable file filter and returns the selected file Enables definition of File Save or File Open dialog with configurable file filter and returns the selected files in a FILE_LIST Returns character used on the client machine as a file separator (“\” on Windows) Returns character used on client machine to separate directory locations on paths (“.

contains the following:
Function
ENABLE_REDIRECT_ON _TIMEOUT DISABLE_REDIRECT_ON _TIMEOUT
Purpose: Enables the time-out monitor and the specification of a redirection URL Switches off the monitor. if you do not call this function before EXIT_FORM.Benefits of the WebUtil Utility (continued) WebUtil_File_Transfer Package: The WebUtil_File_Transfer package contains APIs to transfer files to and from the client browser machine and to display a progress bar as the transfer occurs. The following APIs are included in the WebUtil_File_Transfer package: Function
URL_TO_CLIENT URL_TO_CLIENT_WITH _PROGRESS CLIENT_TO_DB CLIENT_TO_DB_WITH _PROGRESS DB_TO_CLIENT DB_TO_CLIENT_WITH _PROGRESS CLIENT_TO_AS CLIENT_TO_AS_WITH _PROGRESS AS_TO_CLIENT AS_TO_CLIENT_WITH _PROGRESS IN_PROGRESS ASYNCHRONOUS_UPLOAD _SUCCESS GET_WORK_AREA IS_AS_READABLE IS_AS_WRITABLE
Purpose: Transfers a file from a URL to the client machine (and displays a progress bar) Uploads a file from the client to a database BLOB column (and displays a progress bar) Downloads file from a BLOB column in the database to the client machine (and displays a progress bar) Uploads a file from the client to the application server (with progress bar) Transfers a file from the application server to the client (with a progress bar) Returns True if an asynchronous update is in progress Returns a Boolean value indicating whether an asynchronous upload succeeded Returns a work area directory on the application server that is private to the user Returns True if the rules defined in the WebUtil configuration allow the specified file to be read or written to
WebUtil_Session Package: Provides a way to react to an interruption of the Forms session by defining a URL to which the user is redirected if the session ends crashes. the redirection occurs even if the exit is normal
Oracle Forms Developer 10g: Build Internet Applications 24-8
.

and OUTPUT_ARRAY. The WebUtil_Host package also contains the following functions:
Function
HOST
BLOCKING
NONBLOCKING
NONBLOCKING_WITH _CALLBACK
TERMINATE_PROCESS GET_RETURN_CODE GET_STANDARD_OUTPUT
Purpose: Runs the specified command in a BLOCKING mode on the client and optionally returns the return code Runs the specified command in a BLOCKING mode on the client and optionally returns the process ID Runs the specified command in a NONBLOCKING mode on the client and optionally returns the process ID Runs the specified command in a NONBLOCKING mode on the client and executes a supplied trigger when the process is complete Kills the specified process on the client Returns the return code of a specified process as an integer Returns an OUTPUT_ARRAY containing output that was sent to standard output by the specified client process Returns an OUTPUT_ARRAY containing output that was sent to standard error by the specified client process Frees resources of specified client process Returns the process ID of the finished process when a callback trigger executes following a command called from NonBlocking_With_Callback Tests if a process ID is null Tests whether two process IDs represent the same process
GET_STANDARD_ERROR
RELEASE_PROCESS GET_CALLBACK_PROCESS
ID_NULL EQUALS
Oracle Forms Developer 10g: Build Internet Applications 24-9
. Includes two types: PROCESS_ID to hold a reference to a client-side process.Benefits of the WebUtil Utility (continued) WebUtil_Host Package: Contains routines to execute commands on the client machine. a PL/SQL table which holds the VARCHAR2 output from a client-side command.

com/products/forms/htdocs/webutil/webutil. see OTN at: http://otn.htm
Oracle Forms Developer 10g: Build Internet Applications 24-10
. but they can be useful:
Function
DelimStr Show_WebUtil_Information WebUtil_Util
Purpose: Provides interaction with delim ited strings Calls the hidden W ebUtil window to show the version of all W ebUtil com ponents Provides BoolToStr() function for converting Boolean to text
• Internal APIs that should not be called directly For more information about WebUtil. but you can call the following functions:
Function
IsError ErrorCode ErrorText
Purpose: Checks whether the last WebUtil call succeeded Returns the last WebUtil error code Returns the text of the last WebUtil error
•
Utility functions: The following functions are not related to client integration.oracle.Benefits of the WebUtil Utility (continued) WebUtil_Core Package: Contains mostly private functions. including a sample form that showcases its functionality.

Change the Exit button in the Control block. You can import the code from pr24_3. Delete the current code for the button and write code to enable the user to choose a new JPEG image to display in the Product_Image item. experiment with some of the other client/server parity APIs by adding additional code to the New_Image_Btn button.
Oracle Forms Developer 10g: Build Internet Applications 24-25
. You can import the code from pr24_4b.jpg images in the lab directory. Hint: You will need to use CLIENT_GET_FILENAME and CLIENT_IMAGE. Display a message on the status line that contains the value of the ORACLE_HOME environment variable. Try to load one of the . Rename it: New_Image_Btn.READ_IMAGE_FILE. you could: a. the new image is not saved when you exit the form. You can import the code from pr24_4a. In the ORDGXX form. 2. 3. integrate the WebUtil objects and library. b. and then run the form to test it. Note: Because the image item is not a base table item. ?config=webutil.txt in the c:\temp directory that contains the text “Hello World” and invoke Notepad to display this file. If you have time. Relabel it: New Image.txt.Practice 24 1. Set the Forms Builder run-time preferences to use a WebUtil configuration that has been set up for you.txt. 4. For example.txt. Create a file called hello. Save the form. 5.

Multiple Form Applications Overview At the beginning of the course, we discussed the ability to design Forms applications where blocks are distributed over more than one form, producing a modular structure. A modular structure indicates the following: • Component forms are only loaded in memory if they are needed. • One form can be called from another, providing flexible combinations, as required. How does the Application Behave? The first form module to run is specified before the Forms session begins, using Forms Runtime. Other form modules can be opened in the session by calling built-ins from triggers. You can design forms to appear in separate windows, so the user can work with several forms concurrently in a session (when forms are invoked by the OPEN_FORM built-in). Users can then navigate between visible blocks of different forms, much as they can in a single form. You can design forms for a Forms Runtime session according to the following conditions: • Forms share the same database session, or open their own separate sessions.

Oracle Forms Developer 10g: Build Internet Applications 25-3

Multiple Form Session
Forms Runtime Open Open Form A
(Parameters) (Parameters)

Multiple Form Applications Overview (continued) • Database transactions are continued across forms, or ended before control is passed to another form. The commit sequence starts from the current form and follows the opening order of forms. • Forms Builder provides the same menus across the application, or each form provides its own separate menus when it becomes the active form. What Links the Forms Together? Each form runs within the same Forms Runtime session, and Forms remembers the form that invoked each additional form. This chain of control is used when you exit a form or commit transactions. Data can be exchanged between forms as follows: • Through global variables, which span sessions • Through parameter lists, for passing values between specific forms • Through global record groups • Through PL/SQL variables in shared libraries Code can be shared through the following: • Library modules, by attaching them to each form as required • Stored program units in the database
Oracle Forms Developer 10g: Build Internet Applications 25-4

Multiple Form Applications Overview (continued) Benefits of Multiple Form Applications Since you can use different windows and canvases in a form module, wouldn’t it be easier to put the entire application into one large form? Separating your application into multiple forms offers the following benefits: • Debugging: It is easier to debug a small form; once a single form is working perfectly, you have only to integrate it into your application. • Logic modularity:You break the application into pieces based on the logical functions the module is designed to perform. For example, you would not want the functions of human resources management and accounts receivable combined in a single form, and within each of these major functions are other logical divisions. • Network performance and scalability: Sufficient information must be downloaded to describe the entire form before the form appears on the user’s screen. Large forms take longer to download the relevant information, and fewer users can be supported on the given hardware. Break large applications into smaller components based on the likelihood of user navigation, enabling logical areas to be loaded on demand rather than all at once. This approach enables the module to start faster and uses less memory on the application server.
Oracle Forms Developer 10g: Build Internet Applications 25-5

Starting Another Form Module
OPEN_FORM
MDI FORM A OPEN_FORM MDI FORM A FORM B Modeless

How to Start Another Form Module When the first form in a Forms Runtime session has started, it can provide the user with facilities for starting additional forms. This can be performed by one of two methods: • Calling a built-in procedure from a trigger in the form • Calling a built-in procedure from a menu item in an attached menu Built-In Procedures for Starting Another Form You can use the OPEN_FORM built-in to start another form module from one that is already active. This is a restricted procedure, and cannot be called in the Enter Query mode. OPEN_FORM enables you to start another form in a modeless window, so the user can work in other running forms at the same time. You can start another form using OPEN_FORM without passing control to it immediately, if required. This built-in also gives you the option to begin a separate database session for the new form. Instructor Note The broken line indicates that control need not pass immediately to the opened form (depending on the Activate_Mode argument).

Oracle Forms Developer 10g: Build Internet Applications 25-6

How to Start Another Form Module (continued) Syntax:
OPEN_FORM(’form_name’, activate_mode, session_mode, data_mode, paramlist);

Parameter Form_Name Activate_Mode Session_Mode Data_Mode

Paramlist

Description Filename of the executable module (without the .FMX suffix) Either ACTIVATE (the default), or NO_ACTIVATE Either NO_SESSION (the default), or SESSION Either NO_SHARE_LIBRARY_DATA (the default) or SHARE_LIBRARY_DATA (Use this parameter to enable Forms to share data among forms that have identical libraries attached.) Either the name (in quotes) or internal ID of a parameter list

There are two other built-ins that can call another form. This course concentrates on OPEN_FORM, which is considered the primary method to invoke multiple forms, rather than the CALL_FORM or NEW_FORM built-ins. For a discussion of these additional builtins, see the OU Online Library course Oracle9i Forms Developer: Enhance Usability. You can access the online library from the Oracle Education Web page at: http://www.oracle.com/education

Defining Multiple Form Functionality Using OPEN_FORM to Provide Forms in Multiple Windows You can use OPEN_FORM to link form modules in an application and enable the user to work in them concurrently. Consider these requirements for the Summit application: • The CUSTOMERS form must provide an option to start the ORDERS form in the same transaction, and orders for the current customer can be viewed, inserted, updated, and deleted. • The user can see all open forms at the same time, and freely navigate between them to apply changes. • Changes in all forms can be saved together. Using OPEN_FORM to open both forms in the same session satisfies the requirements. However, having both forms open in the same session may have an undesired effect: If changes are made in the opened form, but not in the calling form, when saving the changes users may receive an error message indicating that no changes have been made. This error is produced by the calling form; changes in the opened form are saved successfully, but the error message may be confusing to users. To avoid this, you may decide to open the second form in a separate session, but then changes to each form would need to be saved separately.
Oracle Forms Developer 10g: Build Internet Applications 25-8

with a button to open another form that has all the columns from the EMPLOYEE table so that users can insert new records.customerid.CUSTOMERID as their default.
Example You may have a query-only form that displays employee IDs and names.Other Useful Triggers When Using OPEN_FORM (continued) Example In the opened form (ORDERS). the record status remains NEW.
:ORDERS. so that the user can leave the record without completing it. You can use a When-Form-Navigate trigger in the query-only form to reexecute the query.
Oracle Forms Developer 10g: Build Internet Applications 25-14
. a When-Create-Record trigger on the ORDERS block ensures that new records use the value of GLOBAL. so that when the user navigates back to that form the newly created records are included in the display. When items are assigned from this trigger.customer_id := :GLOBAL.

8. Save.Orders_Button that initializes GLOBAL. 3. 6. Place in on the CV_CUSTOMER canvas below the Customer_Id item. In the ORDGXX form. and then opens the ORDGXX form.
Oracle Forms Developer 10g: Build Internet Applications 25-29
. and run the CUSTGXX form to test the functionality. compile. If you navigate to a second customer record and click the Orders button. 4. the Orders form still displays the records for the previous customer. Add code to the CUSTGXX form so that GLOBAL. 5. Write a When-Create-Record trigger on the ORDERS block that uses the value of GLOBAL.Customer_Id is updated when the current Customer_Id changes. 10.Customer_Id. Change the window location of the ORDGXX form. if required. you can modify the appearance of the ORDXX form to make it easier to read. and run the form to test that it works as a stand-alone. Save. but uses GO_FORM to pass control to ORDGXX if the form is already running. 2. Run the CUSTGXX form and test the button to open the Orders form.Customer_Id as the default value for ORDERS. Save and compile each form. Use the FIND_FORM built-in for this purpose.Customer_Id with the current customer’s ID. create a Pre-Form trigger to ensure that a global variable called Customer_Id exists.Customer_Id. In the CUSTGXX form. If you have time. 13. passing control to it. 11. 9. Write a trigger to reexecute the query in the ORDERS form in this situation.Practice 25 1. 12. Add a trigger to ensure that queries on the ORDERS block are restricted by the value of GLOBAL. Define a trigger for CONTROL. simlar to what you see in ORDERS. 7.fmb. create a CONTROL block button called Orders_Button and set appropriate properties. compile. Alter the Orders_Button trigger in CUSTGXX so that it does not open more than one instance of the Orders form. Save and compile the ORDGXX form.