Wednesday, February 3, 2010

How to add Java bean by writing your own Java code in Oracle forms

Hello everybody,

Today i m going to show u how to add Java bean (Bean area) in Oracle forms 10g and if u want to write some bean for Oracle forms then following are the guidelines

In this Example  (Download zip contains all files)
I will write a very very simple Bean In which i will set its value to System date Time and return it (working as global variable).
I used Oracle JDeveloper Studio 11.1.1.2.0.
 
Things to Remember:
- Whenever u write bean for Forms your class should extends VBean class which is available in frmall.jar $ORACLE_HOME/forms/java directory
- Copy frmall.jar to /lib directory in Jdeveloper installation directory.

Steps:
-Add frmall.jar in Jdeveloper Libraries so u can extend VBean class.


- Write bean code in Jdeveloper (In my example i have created SETMYTIME and GETMYTIME to set and get the value of MyDate string)

-Create a deployment profile JAR type in Properties on the project


- Deploy it using JAR file to $ORACLE_HOME/forms/java or ur application server path.


- Provide ur JAR file name in configuration section archive=frmall.jar,FormProperties.jar in

$ORACLE_HOME/forms/server/formsweb.cfg file
Note: use archive_jinit if u r using Jinitiator plugin

- Create Bean Area in Forms.
- Set its Implementation class property with the fully classified name and path of your bean i.e oracle.forms.custombean.TimeBean in my example.

- You can use SET_CUSTOM_ITEM_PROPERTY procedure to set the Custom events properties to the bean

Set_Custom_Property('BeanArea', RecordNo, PropertyName,value);
- Use GET_CUSTOM_ITEM_PROPERTY to get the value of that property.
Result := Get_Custom_Property( 'BeanArea', recordNo , PropertyName );
-Run the form Press Set Time to bean Button and then Press Get Time from Bean button Result item will display the time when u have pressed the Button :)

Thanks Mr.Francois Degrelle for adding this
You can avoid this Design time message by adding the full classname to your FORMS_BUILDER_CLASSPATH variable


Make sure the Jar file is signed simple way to sign by using sign_webutil.bat

"C:\DevSuiteHome_1\forms\webutil>sign_webutil.bat C:\DevSuiteHome_1\form\java\FormProperties.jar"


This example is very simple but i hope it would help somebody to understand the basics about Writing and using Java Beans for Oracle forms.

Next time i will try to come with some advance example Till then .......


Cheers,
Baig

8 comments:

  1. Hi Baig,
    very nice post, exactlly what i am looking for.
    Only one problem: the download link doesn't work (i get a message "the link is false".
    can u fix this ?

    ReplyDelete
  2. Hi Baig,
    I am really impressed with this article, but the link given in this post is not working.
    Please give a different link.

    Thanks
    Akshat

    ReplyDelete
  3. sorry guys that 4shared is now disabled. i am adding a reminder to myself to upload the sample to my google code account.

    thank you for your patience
    ZB

    ReplyDelete
    Replies
    1. Hi, Zeeshan Baig, I am interested in your code, but the download link is even broken. Thanks if you can fix it, please.

      Delete
  4. Hi Baig,
    Thanks for the post, this is exactly what I am looking for, is it possible to give us an alternate link for the download?
    Many thanks!

    ReplyDelete
  5. Hi Baig
    Nice tutorial and thanks. Does a Java bean used in Oracle Forms11.2 also require Vbean to be the parent class and have frmall.jar in its class path.

    Thanks in advance

    ReplyDelete
    Replies
    1. Hi Janaki,

      I am not sure. I have stopped using Forms 7-8 years ago.

      Regards,
      Zeeshan

      Delete