Solved

How i can use a Java Bean in Forms 6i (Urgent)

Posted on 2002-06-09
2
1,819 Views
Last Modified: 2012-08-14
Hi my name is zeeshan i m getting problem with
using a bean on forms 6i please tell me full steps of using beans from 1 to all i'll be very thankful to him/her
0
Comment
Question by:zeeshan21m
2 Comments
 
LVL 6

Accepted Solution

by:
M-Ali earned 100 total points
ID: 7065098
The following note from metalink may help you:  

Doc ID:  Note:131960.1
Subject:  Using and simulating Image Items in Web Forms
 

*************************************************************
This article is being delivered in Draft form and may contain
errors.  Please use the MetaLink "Feedback" button to advise
Oracle of any issues related to this article.
*************************************************************

PURPOSE
-------

Time and again customers ask for a possibility of using Image Items
in Forms when they run in the web, or, more critical, when they move
a client/server application to the web.

In this article the different possibilities will be discussed,
including the use of Java Beans.

 
SCOPE & APPLICATION
-------------------

The skill of readers may vary from casual to expert depending on which
method will be implemented.
To use an Image Item can be done by a novice.
But to implement a Java Bean that reads/writes to local files
and may also communicate with the database is more complex.



Using and simulating Image Items in Web Forms
---------------------------------------------

 
1.) Using Image Items
    -----------------

    Of course using Image Items is the easiest way of displaying images
    within a Forms module, whether on the web or client/server.
    But when running on the web, there is a restriction that follows from the
    web architecture:
   
    The image files have to be on the Application Server rather than on the
    Client. The file path has to be specified in the local operating system
    naming style.

    Using an Image Item can be done this way:
   
      - create an Image Item named 'image_item' on your canvas.
      - use read_image_file call in the Forms trigger:

        read_image_file('d:\www6i\images\test.jpg','JPG','image_item');


2.) Using a Bean Area to simulate an Image Item and load image files from a URL
    ---------------------------------------------------------------------------

    For this a Java Bean is required.

    Included below is a simple PJC that subclasses
    VBean and is small enough to require no further action such as
    providing a lightweight environment for the bean
    (for a declaration of this see extras\forms\pjc\beanarea
     on the Developer 6i CD).


    Create a file named "PitImageBean.java" from the following code in any directory.
    Compile it using javac.exe or JDeveloper (see Note.130431.1)
    to "PitImageBean.class" and copy this class file to
    ORACLE_HOME\forms60\java\oracle\forms\demos (if necessary, create this directory).


    package oracle.forms.demos;

    import java.awt.*;
    import oracle.forms.ui.*;
    import oracle.forms.handler.*;
    import oracle.forms.properties.*;


    public class PitImageBean extends VBean
      {  private static final ID IMAGEURL = ID.registerProperty("imageURL");

         private Image myImage=null;

         public void setImage(String imageURL)
           {  try
                {  myImage = Toolkit.getDefaultToolkit().getImage(new java.net.URL(imageURL));
                   System.out.println("setImage: imageURL");
                }
              catch (Exception e)
                {  e.printStackTrace();
                }
              repaint();
           }

         public Object getProperty(ID id)
           {  try
                {  return super.getProperty(id);
                }
              catch (Exception e)
                {  e.printStackTrace();
                   return null;
                }
           }


         public boolean setProperty(ID id, Object value)
           {  try
                {  if (id == IMAGEURL)
                     {  this.setImage((String)value);
                        return true;
                     }

                   return super.setProperty(id, value);
                }
              catch (Exception e)
                {   e.printStackTrace();
                    return false;
                }
           }


         public void paint(Graphics g)
           {  try
                {  if(myImage!=null)
                     g.drawImage(myImage,0,0,this);
                }
              catch (Exception e)
                {  e.printStackTrace();
                }
           }
      }
   


    Then in Forms create a Bean Area item named "PITIMAGEBEAN" on the canvas
    and specify for the property "Implementation Class" the value
    "oracle.forms.demos.PitImageBean".

    In order to fill this Bean Area Item at runtime with an image file write the
    following PL/SQL code in a Forms trigger:
    set_custom_property('PITIMAGEBEAN',1,'imageURL','http://test.de.oracle.com/images/test.jpg');

    Of course use your own Server name, virtual directory and file name in the URL.

    This solution is faster than
    using an image item and, more important, any URL can be used that is accessible from
    the Client and this is an improvement for the end user.
    This removes the restriction to use a directory on the Application Server.

    In the next chapters reading from local files and saving to the database
    will be discussed..


3.) Adding local file functionality
    -------------------------------

    Of course it would be nice for end users to load local image files directly
    into the Bean Area.

    This is a bit more complicated, because then the java code would be
    more sophisticated. Moreover, because of security reasons, copying a
    class file would not be enough.
    Instead creating and signing a JAR file is required.
   
    At the moment there is a bug that prevents most local file access,
    see bug 1543274 for the "writing" part of the problem.
    This bug is fixed in 6.0.8.14 which is patch kit 4.

    So in this note a ready solution for this will not be given.

    As soon as the bug is fixed, it would be worth while
    to write Java code to read also from local files.


4.) Adding base table functionality
    -------------------------------

    In order to complete the original image item features it would also
    be nice to be able to save such a simulated image item to the
    database.

    At the moment there is not a way to implement this directly.
    At least the PJC would need a pair of getValue and setValue methods,
    but there is no interface within the Forms runtime
    prepared for this requirement yet.

    What of couse is possible already is to use a pair of
    invisible basetable Textitem and visible Bean Area item (as in chapter 2)
    where the Textitem is based on a varchar2 column
    and the Bean Area item is filled in the Textitem's POST-QUERY-TRIGGER
    by means of a SET_CUSTOM_PROPERTY command.

    Of course the image itself is not in the database but a reference to
    its URL.
    Maybe at the time of the increasing importance of Internet Servers
    this will be a reasonable way, too.




RELATED DOCUMENTS
-----------------

Note 70173.1 handles the deploying of images for iconic buttons
for Webforms
Note 2117949.6 FRM-13008 CANNOT FIND JAVA BEAN
.

 

--------------------------------------------------------------------------------
 
 Copyright (c) 1995,2000 Oracle Corporation. All Rights Reserved. Legal Notices and Terms of Use.  



HTH
Ali
0
 
LVL 5

Expert Comment

by:jpkemp
ID: 9034209
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:
Accept M-Ali's comment as answer
Please leave any comments here within the next seven days.
 
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
 
jpkemp
EE Cleanup Volunteer
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

Why doesn't the Oracle optimizer use my index? Querying too much data Most Oracle developers know that an index is useful when you can use it to restrict your result set to a small number of the total rows in a table. So, the obvious side…
Configuring and using Oracle Database Gateway for ODBC Introduction First, a brief summary of what a Database Gateway is.  A Gateway is a set of driver agents and configurations that allow an Oracle database to communicate with other platforms…
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
This video shows how to configure and send email from and Oracle database using both UTL_SMTP and UTL_MAIL, as well as comparing UTL_SMTP to a manual SMTP conversation with a mail server.

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now