This tip is brought to you by the International Oracle Users Group (IOUG). It has been excerpted from the presentation "Top tips for Web-deployed Forms," originally presented at IOUG! Live 2003 by Peter Koletzke. Become a member of the IOUG to access a repository of technical content created for Oracle users by Oracle users.
Forms runs within a Java Virtual Machine (JVM) inside a browser and offers mechanisms to tap into the JVM using custom Java code. There are a number of ways to use Java and a number of reasons that this is a compelling solution. Even if you have little or no Java language experience, you should be able to use or modify examples of Java code that are available for Forms work. In addition, Oracle's JDeveloper tool (part of the Oracle9i Developer Suite), provides a wizard and documentation to get you started developing and using Java components for Forms.
USE PLUGGABLE JAVA COMPONENTS
Pluggable Java Components (PJCs) are JavaBeans that are either embedded in the form as a separate object (Bean Area on the Layout Editor toolbar) or that act as a substitute for a Forms object such as an item or button. Incorporating PJCs will allow you to extend the capabilities of Forms and solve problems such as how to read and write to the client's file system, how to provide a Java spell checker for a Web form, how to implement timers that fire only on the client.
IMPORT JAVA METHODS
You can create PL/SQL packages that call Java methods (code units) using the Java Importer (Program | Import Java Classes in the menu). This utility creates a package spec and body that can be used to call methods in a specific Java class (JavaBean or other type of class). This works similarly to the FFIGEN utility that is used to create PL/SQL wrappers that call functions in external libraries (such as Windows DLLs). This allows you to call pre-existing functionality that is written in Java or to call Web services. It also allows you to use Java to solve a complex programming problem that PL/SQL cannot handle. The Java Importer is available in Forms 6i release 2 and greater (9i). In addition, with Forms 9i, you can call code in JavaBeans directly without the PL/SQL package created by the Java Importer. The FBEAN built-in package (also documented in online help) contains procedures and functions that allow you to call the JavaBean's methods with or without arguments.
WHY USE JAVA?
Web-deployed Forms applications run on an application server and normally do not allow interaction with the client machine. PJCs allow you to write code that will execute within the client browser's Java Virtual Machine. This opens up many possibilities for integration with other applications, interaction with the client file system, performing functions that are processor-intensive outside of a common server, etc. In addition, Java offers a richer set of UI components than the Forms native toolkit so you can extend your form to do virtually anything. The Java components (Swing controls) are extendable and easily customizable.
Also, if there is a function that you cannot perform with a native Java component, you can write your own component (called a "JavaBean"). Naturally, you need to weigh the time to develop such components with the potential for reuse. You also need to consider potential performance issues that could arise from the extra program layers that Java may require. For example, creating a custom multi-record block component using the Java Swing JTable class and calling Business Components for Java will increase the functionality of the control (users can resize the columns in a JTable class). However, the additional layers required to implement this solution may slow down the Forms built with this control.
Incorporating Java into your form gives you a little experience with the Java language and its development environment without having to worry about Java deployment architectures. It also allows you to maintain and leverage your core competency in Forms technology and continue to use Forms for most requirements. As you use Java more and more in your forms, you may find that Java starts to provide a large part of the functionality and you may think about writing Java applications. Your experience with PJCs will help your transition into the Java world.
IOUG: Become a member of the IOUG to access a repository of technical content created for Oracle users by Oracle users.