This Java Bean allows to process massive updates to the Forms source files (.FMB) through an XML input file.


Purpose

 

The goal is to hide the complexity of the Java/JDAPI stuff for those people that do not have time/skill to implement this Java API.

 
All the work expected to be done on the FMB files is described in a XML file.

JDAPI Utility

Three main sections are implemented to achieve the following:

  • section 1: define the global settings
  • section 2: do the job on all the modules given
  • section 3: do the job on each named module given

This Bean has been constructed as an enhanced Java Bean (using the FBean package), so it can be executed outside the Forms environment, from JDeveloper or from the command line.

I have tested it successfully under Forms 9i and the Sun Java plug in 1.5, but I have also encountered many problems while trying running it with Forms 10g and Sun Java plug in 1.6 or under the JInitiator.

This is the reason why I have added the possibility to run the stuff from the JAR file via the java.exe program called through the Host() Forms built-in.

 At this very moment (version 1.0) it can achieve the following:

 

  • Change the PL/SQL attached libraries name case to lower or upper case.
  • Attach a PL/SQL library
  • Remove a PL/SQL library
  • Add a Forms trigger
  • Remove a Forms trigger
  • Add a program unit
  • Remove a program unit
  • Delete PL/SQL code part from a trigger/program unit
  • Replace PL/SQL code part from a trigger/program unit
  • Add OLB sublassed object
  • do all available property setting on:
    • Alerts
    • Windows
    • Canvas
    • Blocks
    • Items
    • Editors
    • LOVs
    • Record Groups
    • Visual Attributes

 

To know what properties can be set to this last objects, study the JDAPI documentation and particularly the following classes:

 

  • oracle.forms.jdapi.Alert
  • oracle.forms.jdapi.Block
  • oracle.forms.jdapi.Canvas
  • oracle.forms.jdapi.Item
  • oracle.forms.jdapi.Window

 

for instance, here are the properties you can set to an alert:

 // String properties
setAlertMessage(String)
setBackColor(String)
setButton1Label(String)
setButton2Label(String
setButton3Label(String)
setComment(String)
setFillPattern(String)
setFontName(String
setForegroundColor(String)
setName(String
setTitle(String
setVisualAttributeName(String

// boolean properties
setSubclassObjectGroup(boolean)

// integer properties
setAlertStyle(int)
setDefaultAlertButton(int)
setFontSize(int)
setFontSpacing(int)
setFontStyle(int)
setFontWeight(int)
setLanguageDirection(int)


The implementation class of the Bean


     oracle.forms.fd.jdapiutil.JDAPIUtil


Register the bean:

FBean.Register_Bean('BL.BEAN', 1, 'oracle.forms.fd.jdapiutil.JDAPIUtil');


The methods you can call



Switch the logging mode:

FBean.Set_Property('BL.BEAN', 1, 'Log', true);



Set the log filename:

FBean.Set_Property('BL.BEAN', 1, 'LogFilename', 'c:/jdapiutil.log');



Process the XML file:

FBean.Invoke('BL.BEAN', 1, 'doProcess','XML_filename');


If you do not want to use this internal command (bug with some JREs) do as the following:


If internal Then
  FBean.Invoke('BL.BEAN', 1, 'doProcess',:BL.XMLFILE);
Else 
  Declare
    LC$Cmd Varchar2(512) ;
  Begin 
    LC$Cmd := 'cmd /c "' || :BL.JAVA || 'java.exe -classpath ' 
    || :BL.JAR_DIR || 'JDAPIUtil.jar;'
    || :BL.JAR_DIR || '
f90jdapi.jar; oracle.forms.fd.jdapiutil.JDAPIUtil '
    || :BL.XMLFILE || '"' ;
    host(LC$Cmd);
  End;

End if ; 
-- get the log file content --
:BL.LOG := FBean.Get_Property('BL.BEAN', 1, 'LogContent');
Go_Item('BL.LOG');
Edit_Textitem(10,10,500,400) ; 

In this code snippet, I used the Forms 9i version. If you use the Forms 10g version, replace f90jdapi.jar by frmjdapi.jar.

The :BL.JAVA field contains the directory name that contains the java.exe program (generally <devsuite_home>/jre/bin).
The :BL.JAR_DIR field contains the name of the directory where the JAR files are stored (generally <devsuite_home>/forms/java).

 

Run the program from the command line:

Assume the following:

The java.exe program is located in the C:
/Oracle/jdk/bin directory
The JAR files are located in the C:/Oracle/forms/java directory
The XML file full name is : C:/my_XML_file.xml

Open a DOS dialog box and e
nter the following command:

C:
/Oracle/jdk/bin/java.exe -classpath C:/Oracle/forms/java/JDAPIUtil.jar;C:/Oracle/forms/java/frmjdapi.jar; oracle.forms.fd.jdapiutil.JDAPIUtil C:/my_XML_file.xml



Get the log file content:

FBean.Set_Property('BL.BEAN', 1, 'LogFilename', 'c:/jdapiutil.log');

varchar :=
FBean.Get_Property('BL.BEAN', 1, 'LogContent');


The sample dialog


     . Download the jdapiutil.zip file
     . Unzip the file
     . copy the JDAPIUtil.jar file in the <ORACLE_HOME>/forms/java directory

     . Edit your /forms/server/formsweb.cfg file to add  JDAPIUtil.jar and f90jdapi.jar or frmjdapi.jar.
     . Open, compile and run the JDAPIUTIL.fmb module (Oracle Forms 9.0.2)

 

Documentation

 

See the XML syntax documentation

Download an XML file sample

Download the JDAPI documentation

Download the list of JDAPI integer constants

Download the complete JDeveloper project (that contains the Java source files)

You have to add the f90jdapi.jar (forms9i) or frmjdapi.jar (forms10g) to the project libraries.
You also have to indicate the oracle.forms.fd.jdapiutil.JDAPIUtil in the main class of the JAR deployment dialog.  

To implement this Bean in your Forms application, add the JDAPIUtil.jar and the f90jdapi.jar (Forms 9i) or the frmjdapi.jar (Forms 10g) to the archive and archive_jini tags of the /forms/server/forsweb.cfg file.


The JDAPIUtil.jar file read files from the client machine, so it needs to be signed.