Embedding Oracle Forms in your QAFE Application (Part 1)


Using our Oracle Forms Conversion tool, it is possible to convert your forms application to a QAFE web application. In some cases you might want to consider integrating your existing Oracle Forms application with your QAFE web application for a more gradual conversion process.

I assume your Oracle Forms application has been configured so it can be exposed through a Java applet. Documentation on deploying your Oracle Forms application as a Java applet is supplied by Oracle[1] and is only available to applications using Oracle Forms 11g or higher.

Communication between Oracle Forms and the QAFE application is done through JavaScript. In order to establish JavaScript communications between both applications, some additional configuration of your Oracle Forms and QAFE application is required.

This blog explains how to accomplish one-way communication, from your QAFE application to your Oracle Forms.

In a following blog, we will elaborate on two-way communication between your applications.

Setting up your Oracle Forms Application
Before your Oracle Forms application allows JavaScript calls, a new Oracle Form level trigger has to be made available, namely the WHEN-CUSTOM-JAVASCRIPT-EVENT trigger. Note that only one is allowed to be defined per Oracle Form.

The trigger PL/SQL logic, which handles incoming JavaScript calls can look similar to this:

In this case we define an event with the name “my-application-event” which, when raised, will set the value of BLOCK1.ITEM1 to the passed eventValue.

Observe the :system.javascript_event_name and :system.javascript_event_value system variables. The :system.javascript_event_name system variable can be used to differentiate between incoming events raised from JavaScript. Event related data is passed from JavaScript via the :system.javascript_event_value system variable. Data passed from JavaScript to Oracle Forms is passed as a single String, if multiple values need to be passed you could consider separating them using a semicolon or using JSON, then parsing this in your PL/SQL logic.

Modify your Oracle Forms application’s formsweb.cfg configuration file to include the following properties:

The applet_name property will decide the applet’s HTML id attribute of the embedded applet in the HTML output.

The enableJavascriptEvent property configures the Oracle Forms Service for JavaScript binding, allowing JavaScript events to be called to and from the Form.

Setting up your QAFE Application
After configuring your Oracle Forms application, you still have to configure your QAFE application in order to embed the Oracle Forms application, and then call the now exposed JavaScript functions.

To embed the Oracle Forms application, use the frame component in your QAFE application’s panel definition:

The source oracle-forms-applet.html contains your embedded Oracle Forms applet (note: this is an example, your HTML code might vary depending on your application setup. Specific Oracle Form related arguments and path variables have been masked):

Calling Oracle Forms events using JavaScript
Now that we have an Oracle Forms application embedded in QAFE, we want to be able to raise events within the Oracle Form. This can be done through the now exposed raiseEvent JavaScript method:

The raiseEvent JavaScript function is made available by the embedded Oracle Form, if JavaScript handling is enabled as explained earlier.

The first argument of this function is the event name corresponding with the event name defined in the WHEN-CUSTOM-JAVASCRIPT-EVENT trigger code.

The second argument is the payload string containing the string formatted argument(s).

It is recommended to wrap the raiseEvent method in a custom defined method, defining that in a separate JavaScript file (e.g. oracleforms.js) and including it in the head section of <qafe-application-root>/webapp/QAFEGWTWeb.jsp file:

Now, when defining your events in your QAFE application’s QAML code you can use the call-script built-in to call either the raiseEvent method directly, or your custom defined method:

If the steps above were succesfully executed, you should now be able to manipulate the embedded Oracle Forms application from your QAFE web application.


Leave a Reply

Your email address will not be published. Required fields are marked *