Purpose
Here is a Java Bean that allows reading, displaying with scaling and writing images.
(See the last
evolution of this solution here)
This Bean allows scaling images to fit the target item
size, and includes a FileChooser with image preview dialog.

This JavaBean connects to the database through the JDBC driver to read and write the images, and does not need
the Webutil library to pick up the image files from the JAR file, the client machine files or the Internet.
The Java code
HandleImage.java
LectureBlob.java GetImageFileName.java
The implementation class of the Bean Item
oracle.forms.fd.HandleImage
The methods you can call
Set the connection string
Set_Custom_Property('BLOCK.ITEM',1,'SETCONN','the_connection_string');
e.g. :
Set_Custom_Property( 'BL.BEAN', 1, 'SETCONN', 'jdbc:oracle:thin:@my-machine:1521:XE' ) ;
(Provide the complete jdbc:oracle:thin:... syntax)
Set the username
Set_Custom_Property('BLOCK.ITEM',1,'SETUSER','username');
Set the
password
Set_Custom_Property('BLOCK.ITEM',1,'SETPWD','password');
Set the database image table information
Set_Custom_Property('BLOCK.ITEM',1,'SETTABLEINFO','p1,p2');
p1 is the table name that holds the image Blob column
p2 is the Blob column name that holds the image
e.g.:
Set_Custom_Property( 'BLZ.BEAN', 1, 'SETTABLEINFO', 'PHOTOS,IMAGE' ) ;
The instruction above indicates that the PHOTOS table handle images
in the IMAGE Blob column..
Read an image from a file
Set_Custom_Property('BLOCK.ITEM',1,'READIMGFILE','the_complete_filename');
e.g.:
Set_Custom_Property( 'BLZ.BEAN', 1, 'READIMGFILE', 'D:/image.jpg' ) ;
Read an image from the database
table
Set_Custom_Property('BLOCK.ITEM',1,'READIMGBASE,'where_clause');
e.g.:
Set_Custom_Property( 'BLZ.BEAN', 1, 'READIMGBASE', 'IDENTIFIANT=20' ) ;
where_clause is the SQL clause to identify a unique row to update in the table. The above instruction will be interpreted as :
Select IMAGE From PHOTOS Where IDENTIFIANT=20
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','where_clause');
e.g.:
Set_Custom_Property( 'BLZ.BEAN', 1, 'WRITEIMGBASE', 'IDENTIFIANT=20' ) ;
where_clause is the SQL clause to identify a unique row to update in the table. The above instruction will be interpreted as :
Update PHOTOS Set IMAGE = ? Where IDENTIFIANT=20
Put 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:
When-New-Record-Instance trigger:
If :PHOTOS.IDENTIFIANT is not null
Then
Set_Custom_Property( 'BLZ.BEAN', 1, 'READIMGBASE', 'IDENTIFIANT=12' ) ;
Else
Set_Custom_Property( 'BLZ.BEAN', 1, 'CLEAR', '' ) ;
End if ;
:BLZ.IMG_SIZE := Get_Custom_Property( 'BLZ.BEAN', 1, 'GETSIZE' ) ;
Set the display image scalling
This function concerns only the image displayed. The image stored with the WRITEIMGBASE method will be the initial
image.
Set_Custom_Property( 'BL.BEAN', 1, 'SCALE_IMAGE' , 'Width=x,Height=y' ) ;
Both Width and Height parameters must be
transmitted
x and y can take the following values:
Any value greater than 0 that express an absolute size in pixels
the special value: FIT that extend to fit the exact size of the image panel' size
-1 that to keep the corresponding aspect ratio
0 that indicates no scale at all
permission java.net.SocketPermission "machine-name:1524-", "accept,connect,listen,resolve";
permission java.security.AllPermission;