Writing event handlers for items on forms
You can code JavaScript and PL/SQL event handlers to customize the layout and operation of items on forms in sophisticated ways:
JavaScript event handlers can be used to customize the behavior of form items, such as buttons, check boxes, lists, text boxes, and so on.
PL/SQL event handlers can be used to customize the behavior of buttons only.
Refer to your JavaScript and PL/SQL documentation for descriptions of the events that are available to you in Oracle Portal.
Note: the version of JavaScript that you use must be supported by your browser.
An
in-depth knowledge of JavaScript and PL/SQL is required to
successfully include event handlers in your forms.
If you code both a JavaScript event handler and a PL/SQL event handler for the same button, be careful to avoid potential conflicts between the execution of the two scripts.
To write a JavaScript event handler for an item on a form:
On the Oracle Portal Home page, click
on the shortcut bar.
Click the providers tab in the Oracle Portal Navigator.
The Name column of the Navigator displays the names of all providers in which you have privileges to build database portlets.
Open an existing form or create a new form that includes the item for which you want to write an event handler:
To create a new form, click the name of the provider in which you want to create the form. Click Create, then choose Form. Select the type of form you want to create to display the Form Builder Wizard. Work through the wizard to the Formatting and Validations Options step.
To open an existing form, click the name of the provider that contains the form. Scroll to the form. In the Action column, click Edit to display the Formatting and Validation options.
In the left frame, click the name of the button for which you want to write a JavaScript event handler.
In the right frame, scroll to JavaScript Event Handlers.
Choose the required event for the item from the list, and type the JavaScript to be executed when the event occurs.
Example 1. To convert a value in a text box or text area input field to upper case whenever the field loses focus, choose the onBlur event and type the following JavaScript:
this.value = this.value.toUpperCase();
Example 2. To add a confirmation when the end user clicks a button before submitting a form, choose the onClick event and type the following JavaScript:
return confirm('Are you sure you want to submit the form?');
This displays a prompt dialog where the end user can click OK or Cancel; clicking OK submits the form.
Example 3. To verify that a value entered by the end user is a number only, choose the onChange event and type the following JavaScript:
if (isNaN(this.value)) {
alert('Please enter a valid number.');
}
For additional information about writing advanced JavaScript event handlers, see your browser's documentation.
To write a PL/SQL event handler for a button on a form:
Follow steps 1-4 above.
In the left frame, click the name of the button for which you want to write a PL/SQL event handler.
In the right frame, scroll to PL/SQL Button Event Handler.
To use a pre-defined event, choose the required event for the button from the list. To create a custom event, choose Custom, and type the associated PL/SQL code.
What are forms?
What are Master-detail forms?