Oracle Forms Community-
Pluggable Java Components & Java Beans' librarywarning :
The material provided on this site does not come from Oracle and is not supported by OracleJoin us on theforms.pjc.beanforum

(See the last evolution of this solution here) When you load an image within Forms with the Read_Image_File() built-in, you can notice a certain lack of quality, both in the Forms Image item display quality and in the real information stored in the blob column. The image seems to be compressed before it is stored in the database. This compression rate is between 25 and 50% ! This Java Bean allows to load images from a file, then store them in the database.

The Forms sample dialog provided with the article uses two image rooms:

- The first one is a standard Forms Image item that is populated with the Client_Image.Read_Image_File() Webutil function that populates the PHOTO blob column.

- The second one is the Java Bean itself that populates the PHOTO_JAVA blob column.

As you see as follows, the Read_Image_File() function can drastically compress the initial image:

This JavaBean connect to the database through the JDBC driver to read and write the images. Of course, some of you can complain that this solution needs a second connection, the loading of the classes12.jar file on the client machine, so it is "deconnected" from the Forms transaction. For this very moment, my answer is : everything has its price, and if you need to keep and display the real quality of the images in your Forms application, this bean is the one you need.

unique_ID is the value to identify a unique row to update in the table. The above instruction will be interpreted as : Select PHOTO_JAVA From PHOTOS Where IDENTIFIANT = 1

Put this method into the When-New-Record-Instance block-level trigger

Write an image to the database table

Set_Custom_Property('BLOCK.ITEM',1,'WRITEIMGFILE','unique_ID');

e.g.:Set_Custom_Property( 'BLZ.BEAN', 1, 'WRITEIMGBASE', '1' ) ;

unique_ID is the value to identify a unique row to update in the table.The above instruction will be interpreted as : Update PHOTOS Set PHOTO_JAVA = ? Where IDENTIFIANT = 1Put this method into the Post-Insert and Post-Update block-level triggers

Clear the image

Set_Custom_Property( 'BL.BEAN', 1, 'CLEAR' , '' ) ;

This function has to be called in a When-New-Record-Instance trigger if the record does not exist:

.Download the handleimage.zip file . Unzip the file . run the create_table.sql under the Oracle user you want to test (It creates the sample image table). . copy the handleimages.jar file in the <ORACLE_HOME>/forms/java directory . Edit your /forms/server/formsweb.cfg file to add both handleimages.jar and classes12.jar (the classes12.jar is located in the <DEV_HOME>/jdbc/lib directory. add a copy of this file in the <DEV_HOME>/forms/java directory). . Open the HANDLEIMAGE.fmb module (Oracle Forms 10.1.2) . Compile all and run the module

. Enter a valid file name in the Image File name item then press the Read image file button

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

Partager cet article

commentaires

Jacob02/04/2007 10:38

Hi FrancoisI've studied your code for this PJC, because I need to create something similar myself. There is one aspect, that makes your approach unusable to me though, and that's the fact, that your PJC requires the client to actually be able to access the database directly. In a web deployment, where the only access to the database is through the Application Server, it's impossible to do it like this. What I'm wondering is - wouldn't it be a better idea to use WebUtil to physically transfer the file to the application server, and as soon as the transfer has completed, invoke a server-side class made with the Java Importer to store the image in a specific BLOB? Have you ever tried doing it this way?Thanks,Jacob

Oracle Forms community02/04/2007 20:56

My goal was to not use the Webutil library. In fact, what I am really targeting is to pass the binary content from the Bean to Forms, then use the current connexion to store the image into the database. At this moment, I am not able to manage this ; for an unknown reason, 5 characters are misinterpreted then poison the whole image.Francois

piotr19/03/2007 14:04

I read image from local mashine in item bean but I would like to off border.
help me please

Hi, I've been tried your pjc, and I've 2 questions:
1.- Why the only image file types i can read from file are JPEG files and not TIFF or BMP types?
2.- When I try to read a blob column from the database, the ii.getIconWidth() and ii.getIconHeight() methods returns -1 (both methods) ? In fact I cant read/write any image file types from / to database, what could be wrong?
Thanks so much for this site, It's very useful

Oracle Forms community04/01/2007 11:51

1. Yes, the default images format read by the component are the web ones.If you want to load other types, you have to use the Java Advanced Imaginghttp://java.sun.com/products/java-media/jai/iio.html.2. When I try to read a blob column from the database...use the Set_Custom_Property( 'YOUR_BLOCK.YOUR_BEAN', 1, 'SETLOG' , 'true' ) ; to output messages to the Java console when using this bean. You'd probably get an error message.Francois

Michael Friedman16/10/2006 04:28

I googled Distrib but could not find it.

Can you give a pointer?

Also, is it suitable for a web based deployment to anonymous users?

Oracle Forms community16/10/2006 09:46

Sorry, The product that I talked about is an internal made soft.It appears that teledistribution softwares are pretty expansive. More simpler is to use .bat files or VBS (Visual Basic Script) in conjonction with a logon.bat file.If you cannot find anything about this, I will send you an example in a few days.

Michael Friedman06/10/2006 01:56

Any solution that requires manually editing files on the client doesn't seem very practical.
Do you have any thoughts on how to manage deployment?

Oracle Forms community06/10/2006 07:39

Some products are made to accomplish this task. At startup, they load onto your machine all the programes you need, and are able to copy anything, like a particular tnsnames.ora file for instance. My company uses : Distrib, but you could probably find something else.Francois

The opinions expressed in this site are those of individual authors. This site is not owned or sponsored by Oracle Corporation. Contact us at forms.pjc.bean@free.fr