|
Here is the quickest way to start using Pluggable
Java Components (PJC) in Oracle9i Forms. No Java knowledge
is needed to complete this simple tutorial. You'll need an
installation of Oracle9i Developer Suite with Oracle9i Forms
and Oracle9i
JDeveloper. The PJC we are going to create extends the functionality of a regular Form's text_item and enables it to react to single keystrokes in the field.
Important note: The Java language
is case sensitive so watch out for upper/lower case.
Creating a new PJC in Oracle9i JDeveloper
A Pluggable Java Component (PJC)is used to
replace a default Forms component (like a button or a text_item)
with a new component with new capabilities.
1. Start Oracle9i JDeveloper from your programs->oracle9i
Developer Suite->JDeveloper->JDeveloper icon.
2. Right click on the Workspaces node and choose "New
Workspace". Show
me.
3. Name the directory and file "pjc" and click "OK".
Show
me
4. Name your project and directory "pjc" in the
new project dialog and click "OK". Show
me.
5. Right Click on the pjc.jpr node and choose "New".Show
me.
6. From the New Gallery choose beans and "Oracle Forms
Pluggable Java Component". Show
me.
7. In the dialog box that appears change the package name
to "pjcs" and choose "oracle.forms.ui.VTextField"
in the Extends list box. Show
me.
8. A new empty PJC that behaves like a regular Form Text Item
has been created for you. You are now ready to change it's
default behavior.
Note: the package name and PJC name are going to be used later
in your form as the implementation class so make a note of
them.
Customizing the PJC
By default a PJC behave exactly like the "regular"
Forms object. In this section we are adding new functionality
to the default behavior of our PJC.
1.Right click on the PJC1.java file and choose the UI Editor.
Show
me.
2. Use the property inspector to change the default settings
of the PJC like the background color. Show
me.
3. Switch to the events tab in the property inspector. This
is where you can define event for the PJC. Show
me.
4. Double click the first "key pressed" event in
the events tab. Show
me
5. Accept the defaults for the event template. Show
me.
6. You are now in the code editor again. Your cursor is positioned
in the event you just defined and you are ready to add Java
code. Luckily Oracle9i JDeveloper can help you write Java
code, even if you haven't done this before.
7. Start typing the following "if (this."
if you wait a second a window will pop up and help you find
methods that you can call. Show
me.
8. Continue typing "gett"
and select the getText method from the list. Show
me.
9. Continue typing the complete
event code using Oracle9i JDeveloper to help you write
your code. Show
me.
10. Compile your project by pressing ALT+F9 and make
sure you don't have any errors. (If you encounter errors make sure that your code includes an import java.awt.Color; line).
Deploying the PJC
In order for the Oracle9i Form applet to be able to use our
new component we need to package it up and place it in an
accessible place for the Web server.
1. Right Click on the pjc.jpr node and choose "New".
Show
me.
2. From the "New Gallery" choose "Deployment
Profile" "JAR File - Simple Archive".
Show
me
3. Accept the default for the deploy file name. Show
me
4. Accept the defaults in the JAR file property window. Show
me.
5. Right click on the archive1.deploy file in the navigator
and choose "Deploy To...". Show
me
6. Change directory to "%9iDS_HOME%\forms90\java"
and deploy your JAR file to this directory. Show
me
7. Your PJC is now packaged and ready to be used by Oracle9i
Forms.
Using the PJC in your Form
1. Create a new Form in Oracle9i Forms and
add a new TEXT_ITEM to it.
2. Change the implementation class property of the
Text Item to pjcs.PJC1 (watch for upper/lower case).
Show
me.
3. Before you run your form you need to add the JAR file we've
created to the HTML file that will load the Forn.
4. Open the "%9iDS_HOME%\forms90\server\formsweb.cfg"
file and add a new configuration called [PJC] at its
end. Show
me.
5. Save the file and exit.
6. Now run your Form from inside the Oracle9i Forms Developer.
The form is running using the default configuration, therefore
doesn't use the JAR file, the PJC doesn't work.
7. Exit the form but don't close the browser.
8. Change the URL used to run your form and add "config=pjc&"
after the "f90servlet?" part of the URL.
Show
me
9. Your Form should run now with the PJC working try entering
the field and typing a value starting with "a" the
text item would turn green. Show
me
10. If you type a value starting with "b" the item
would change color to cyan. Show
me
Learn How-To Debug Your PJC Here
See How-To Debug Your PJC Here
|