Oracle Forms and JavaScript Integration 6-3
6.2 About JavaScript Events Calling into Oracle Forms
You can also allow JavaScript calls into Oracle Forms by using JavaScript in the Web page that hosts the Forms applet. There is new functionality available on the
embedded Forms object in the DOM Document Object Model tree. You use JavaScript to do:
document.forms_applet.raiseEventevent_name, payload; The assumption here is that you have set the ID configuration variable to forms_
applet. When the surrounding Web page executes this JavaScript code, Oracle Forms fires a
new type of trigger called WHEN-CUSTOM-JAVASCRIPT-EVENT. In this trigger there are only two valid system variables: system.javascript_event_value and
system.javascript_event_name. These variables contain the payload and event name that were passed into Forms through the raiseEvent method. On calling the
raiseEvent method, a trigger named WHEN-CUSTOM-JAVASCRIPT-EVENT is fired on the server side.
declare event_val varchar2300:= :system.javascript_event_value;
begin if :system.javascript_event_name=show then
handleShowEventevent_val; elsif:system.javascript_event_name=grab then
handleGrabEventevent_val; else
null; end if;
end;
This PLSQL code recognizes two events: show and grab. Any other name is ignored.
6.2.1 Why Let Events Call into Oracle Forms?
You can synchronize an HTML based application, whether it is Java-based or otherwise, with a Forms-based application in the same hosting Web page. For
example, you can use the HTML-based application to query data and use Forms to update it if, and only if, the user has the correct access privileges.
6.3 Integrating JavaScript and Oracle Forms
This section describes an example for integrating JavaScript in Oracle Forms application. To integrate JavaScript in Oracle Forms applications, perform the
following steps:
1.
Build a Forms application using the JavaScript events as described in Section 6.1,
About Oracle Forms Calling External Events and
Section 6.2, About JavaScript Events Calling into Oracle Forms
. Use the :system.javascript_event_name and :system.javascript_event_value in the
WHEN-CUSTOM-JAVASCRIPT-EVENT trigger. Compile the module. For more information, refer to the Forms Builder Online Help.
2.
Create an html file for example, test.html that the Forms servlet will use as a template when generating the HTML page used to start an Oracle Forms
6-4 Forms Services Deployment Guide
application. Copy the file to the Forms configuration directory: ORACLE_ INSTANCEconfigFormsComponentformsserver
3.
Copy any required images, html files, JavaScript files, and css files to the following directory: DOMAIN_HOMEserversWLS_FORMStmp_WL_
userformsapp_11.1.1random_string2war
4.
Create an html file that uses the JavaScripts for example, js.html and invokes the servlet URL.
5.
Using Enterprise Manager, create a new configuration section or modify an existing one and enable enableJavascriptEvent. Set baseHTMLjpi to
test.html.
6.
Using Enterprise Manager, edit the default.env file and add the directory where you saved the forms application to the environment variable FORMS_PATH.
7.
Run the application by using the URL in your browser: http:localhost:9001formsjs.html
6.4 Configuration of formsweb.cfg
The administrator of the Forms application can enable or disable JavaScript integration by setting the parameter enableJavascriptEvent in formsweb.cfg to true or
false. If enableJavascriptEvent is not set to true, then calls from JavaScript would be ignored. The applet_name parameter must be set to the value that is used by
the HTML developer to reference the forms applet via document.applet_name.
The administrator can also set JavaScriptBlocksHeartBeat default value is false in formsweb.cfg to true. This blocks Forms HEARTBEAT during the time
JavaScript is executed. If the JavaScript calls complete execution before the FORMS_ TIMEOUT period, setting JavaScriptBlocksHeartBeat to true provides an increase in
performance by avoiding additional network messages.
Note that if JavaScriptBlocksHeartBeat is set to true, Forms would abnormally terminate if the time taken for executing a JavaScript is more than FORMS_TIMEOUT.
6.5 Configuration of Environment Variables