Overblog
Suivre ce blog
Editer l'article Administration Créer mon blog
8 juillet 2006 6 08 /07 /juillet /2006 16:27

Purpose

Here is a Java Bean that allows to write/read files on the client machine without installing Webutil.

The Java code

     clientfile.java


Register the Bean

The bean must be registered before you can call its methods.
Because the Bean cannot be registered at the very start of the form (When-New-Form-Instance for example), we need to place this instruction in a When-Timer-Expired trigger:

When-New-Form-Instance trigger:

DECLARE
    timer_id Timer;
BEGIN
    timer_id := CREATE_TIMER('bean_timer', 200, NO_REPEAT);
END;



When-Timer-Expired trigger:

FBean.Register_Bean('BL.BEAN_ITEM',1,'oracle.forms.fd.ClientFile');


In my sample dialog, I have a bean area called BEAN_ITEM in the BL block.

The bean is registred, now, so we can invoke its methods:


The methods you can call

Set the filename

FBean.Invoke('BLOCK.ITEM',1,'setFileName','the_file_name');


Write the text to this file

FBean.Invoke('BLOCK.ITEM',1,'writeToFile','the_text');


Append the text to this file

FBean.Invoke('BLOCK.ITEM',1,'writeAppendToFile','the_text');


Read the text from this file

varchar2 := FBean.Invoke_Char('BLOCK.BEAN',1,'readFromFile','');


Set the log mode to output the Bean messages

FBean.Invoke('BLOCK.ITEM',1,'SetLog','');


In the sample dialog provided with the article, I use 2 buttons:

- One to write the text:

If :BL.filename is not null Then
   -- set the log on --
   FBean.Invoke('BL.BEAN_ITEM',1,'SetLog','');
   -- set the file name --
   FBean.Invoke('BL.BEAN_ITEM',1,'setFileName',:BL.filename);
   -- write the text --
   FBean.Invoke('BL.BEAN_ITEM',1,'writeToFile','"' || :BL.write || '"');
End if ;   

- Another to read the text:

If :BL.filename is not null Then
   -- set the log on --
   FBean.Invoke('BL.BEAN_ITEM',1,'SetLog','');
   -- set the file name --
   FBean.Invoke('BL.BEAN_ITEM',1,'setFileName',:BL.filename);
   -- read the text from the file --
   :BL.READ := FBean.Invoke_Char('BL.BEAN_ITEM',1,'readFromFile','');
End if ;   


The sample dialog

clientfile


     . Download the clientfile.zip file
     . Unzip the file
     . copy the clientfile.jar file in the <ORACLE_HOME>/forms/java directory
     . Edit your /forms/server/formsweb.cfg file
     . Open the CLIENTFILE.fmb module (Oracle Forms 10.1.2)
     . Compile all and run the module



Note : If you rebuild the jar file, it has to be signed. (the clientfile.jar file provided in this article is already signed).

Partager cet article

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

commentaires

Raj 09/07/2015 21:42

Hi,
Thanks for providing the solution. I've deployed ur sample FMB and all JAR files in specified location.
But it's not working. Could you please give me the check list to configure the java files to access by forms? So that i can make the configuration settings accordingly.

Regards,
Raj

Moheb 26/09/2013 21:29


It doesn't support unicode, you could change the read/write methods to support this important functionality using UTF-8 encoding like the following:


FileWriter fw = new FileWriter(new OutputStreamWriter(new FileOutputStream(file), "UTF-8")); 

Humayun 06/08/2015 09:51

Dear Sir, i want to add this form on oracle ebs r12. i have customize this form according to ebs formate and add java bean and its all functionality. but i am failed to configure jar files and its entry in formsweb.cfg because ebs replace its with default settings. have you any solution?

Oracle Forms community 27/09/2013 07:53



Ok. Many thanks for the tip  ;-)