QAFE

Embedding Oracle Forms in your QAFE Application (Part 2)

In part 1 we discussed communication from QAFE to Oracle Forms. This blog will explain communication from Oracle Forms to QAFE. To allow for Oracle Forms integration in QAFE a few changes are needed in both the web-application and Oracle Form.

(Note: currently the following only works when client-side processing is enabled)

Prepare Web-Application & QAFE Application

Passing data from Oracle Forms to QAFE is, usually, a two step process. From Oracle Forms you will be calling a JavaScript method with the values you want to pass to QAFE. This JavaScript method in turn calls a QAFE event passing needed values.

Prepare QAFE Application

Add the event which will be invoked from the Oracle Form to the QAFE Application:

Listing 1: QAFE Application

Prepare Web-Application

Add a JavaScript function to the Web Application that contains the Oracle Forms applet. This function will call the QAFE provided JavaScript function invokeQafeEvent, which invokes a QAFE event. This newly added function can also be used to handle the embedded Oracle Forms applet e.g. hide it.

The invokeQafeEvent takes the following parameters:

Parameter    Type    Description
eventId         String   Id of the QAFE event. If null, nothing will happen.
windowId     String   Id of the QAFE window. If null, QAFE will try for a global event with the given id.
appId            String   Id of the QAFE application. If null, nothing will happen.
data              Map      Data needed in the QAFE event. If null, the data in the QAFE event will be null.

Listing 2: JavaScript function to invoke a QAFE event.

Prepare Oracle Forms Application

In the Oracle Form make use of one of the two procedures available within the web Built-in package provided by Oracle to call the previously defined JavaScript function:

  • web.javascript_eval_expr is a procedure which takes two arguments: an expression and a target, both of datatype VARCHAR2. If the target argument is null, then it is executed in the page or frame in which the Forms applet is embedded.
  • web.javascript_eval_function is a function, which takes the same arguments as above, and returns a VARCHAR2 value.

Both web.javascript_eval_expr and web.javascript_eval_function have the same functionality except that web.javascript_eval_expr does not send any return value from the client to the Oracle Form. If your application does not expect a return value, use web.javascript_eval_expr. Then the additional network trip that is required to carry the return value from the client to the Oracle Form is eliminated (see figure 1 below).

Since the return value of the web.javascript_eval_function is a VARCHAR2 some syntax might need to be devised when multiple return values or return values of a different datatype are desired. For example, concatenating multiple values separated by a semicolon.

PL/SQL editor

Figure 1: Oracle Forms statement to execute JavaScript.

Conclusion

A minor disadvantages is that, due to a limitation of Oracle Forms, the return value of web.javascript_eval_function is a VARCHAR2 and some additional parsing is required when passing more complex data back to Oracle Forms.

Being able to integrate Oracle Forms and QAFE provides the option to move gradually from Oracle Forms to QAFE. This has several advantages: start using the resulting web-application as soon as the first Oracle Forms are converted; opt to only convert the most prominent Oracle Forms in your application and remove the bottlenecks in your workflow; convert Oracle Forms to the extend of your budget, with the option to convert the rest later.

References

[1] http://docs.oracle.com/cd/E23943_01/web.1111/e10240/javascript.htm

Leave a Reply

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