Overblog Suivre ce blog
Editer l'article Administration Créer mon blog
6 novembre 2007 2 06 /11 /novembre /2007 13:11

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



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

// boolean properties

// integer properties

The implementation class of the Bean


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);
    LC$Cmd Varchar2(512) ;
    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 || '"' ;

End if ; 
-- get the log file content --
:BL.LOG := FBean.Get_Property('BL.BEAN', 1, 'LogContent');
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:

/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)




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.

Partager cet article

Repost 0
Published by Oracle Forms community - dans Bean - general
commenter cet article


Carlos 30/01/2011 23:32

Thank you.  Finally, during
these days I edited the source to fix some others things, which are mentioned below for the improvement of the tool.



- if(! scanItems(sModuleContent, sBlockName … I think is missing in
doProcess (line 561 aprox.)

- Under scanItems routine , in the call to doAction,  sBlockName and sName are apparently switched (line 1735 aprox.)


My comment number 2 referred it to the single modules section as well, as
an example if you want to modify a property of the “item1”,  and a property of the “item2”, I have to close and open a new
module sequence, if not all the property requested to be applied in item2 are applied to item2, is like it doesn’t change the name.


Thank you anyway for your effort, I’ve saved a lot of time using this tool
even though the issues that I dealt with.


Oracle Forms community 01/02/2011 07:08

Thanks for the information. Could you tell me what you put in your XML file so that I could reproduce the issue with the item properties ?

Carlos 27/01/2011 21:28

In addition to the oldest .jar file than .zip source project.  When you try to modify more that one object (name, i.e.: canvas element1 and element2) all the attributes that
you want to modify in element2 are not applied to it, instead of they are applied to the element1.

Oracle Forms community 29/01/2011 08:01

I have re-uploaded the zip file that contains a new JAR corresponding to the last version - 1.4
To solve the multiple operation issue on the same object, you have to repeat the whole tag for each different property:

  setCommentblock comment 


Carlos 26/01/2011 22:24

The jdautil is wrong.

                // --------------------
                //  scan for LOV
                // --------------------
                if(! scanRecordGroups(sModuleContent, null)) throw new ErrorException(" !! Process aborted !!");
                // ----------------------------
                //  scan for record groups
                // ----------------------------
                if(! scanLovs(sModuleContent, null)) throw new ErrorException(" !! Process aborted !!");



Oracle Forms community 27/01/2011 07:16

Sorry, I don't understand. Could you give some details about what is wring ?