Overblog Suivre ce blog
Administration Créer mon blog
30 janvier 2007 2 30 /01 /janvier /2007 14:50
Purpose

Here is a Java Bean that allows to paint the current canevas with a Java gradient.
It needs the JRE 1.4 (Sun Java Plug-in)

     Gradient Canevas



The Java code

     PaintCanevas.java



The implementation class of the B
ean

     oracle.forms.fd.PaintCanevas


The methods you can call


  • Set the gradient parameters

    Set_Custom_Property( 'BL.BEAN', 1, 'SET_GRADIENT_COLORS', '255,255,0,255,0,0');

    It takes two RGB colors, the starting color then the ending color.


  • Set the Horizontal cycle

    Set_Custom_Property( 'BL.BEAN', 1, 'SET_H_CYCLE', 'cycle_info' ) ;

    Set the Horizontal cycle when you want to have a repetitive gradient.

    You can provide a value exprimed in pixel or a fraction

    e.g.: 

    - repeat the gradient 2 times horizontally:

    Set_Custom_Property( 'BL.BEAN', 1, 'SET_H_CYCLE', '/2' ) ;





    - repeat the gradient each 50 horizontal and vertical pixels

    Set_Custom_Property( 'BL.BEAN', 1, 'SET_H_CYCLE', '50' ) ;
    Set_Custom_Property( 'BL.BEAN', 1, 'SET_V_CYCLE', '50' ) ;






  • Set the Vertical cycle

    Set_Custom_Property( 'BL.BEAN', 1, 'SET_V_CYCLE', 'cycle_info' ) ;

    See the Horizontal cycle explanation.


  • Set the gradient direction

    Set_Custom_Property( 'BL.BEAN', 1, 'SET_GRADIENT_DIRECTION', 'direction' ) ;

    Where direction can take one of the following values:

      LeftToRight : Left to Right
      UpToDown : Up to Down
      LeftUpToRightDown : Left Up to Right Down
      LeftDownToRightUp : Left Down to Right Up

Of course, you can have one Bean per canevas, so you can have some nice mixed compositions with multiple canevases !




The sample dialog

   . Download the gradientcanevas.zip file
   . Unzip the files
   . copy the paintcanevas.jar file in the /forms/java directory
   . Edit your /forms/server/formsweb.cfg file to add the jar file
   . Open the GRADIENT_CANEVAS.fmb module (Oracle Forms 9.0.2)
   . Compile all and run the module

 

 

 
Repost 0
Published by Oracle Forms community - dans Bean - general
commenter cet article
9 janvier 2007 2 09 /01 /janvier /2007 18:48

Purpose

Here is a Java bean that allows to Drag 'n Drop between Forms items.

Drag 'n Drop

You can Drag 'n Drop between mono and multi-line text fields and between images.

Because the "real Java" Drag 'n Drop is not implemented in the Forms application, This one is "hand made".
So when you release the mouse button to drop the object, you have to move the mouse about one pixel to
really drop the object.

Press the Ctrl keybord key if you want to keep the original object (COPY).

This demo load the image from the c:/wile.jpg image file, so copy this file from the zip file to your c:/ directory.


The Java code

     DnD.java



The implementation class of the Bean Item

     oracle.forms.fd.DnD




The sample dialog

     . Download the DnD.zip file

     . Unzip the file
     . copy the DnD.jar file in the <ORACLE_HOME>/forms/java directory

     . Edit your /forms/server/formsweb.cfg file to add this jar file
     . Open the DnD.fmb module (Oracle Forms 9.0.2)
     . Compile all and run the module

Repost 0
Published by Oracle Forms community - dans Bean - general
commenter cet article
5 janvier 2007 5 05 /01 /janvier /2007 13:22

Purpose

Here is a collection of PJCs that allow to have multiline labels and tooltips.
The tooltips can have a nice decoration like Java gradients, and be displayed anywhere on the screen.

It needs, at least, the Sun Java plugin 1.4 to run. It won't run against the JInitiator.


        Multiline

All the properties can be set within the Tooltip item property.
So it is convenient for modules generated by Oracle Designer for instance
(no need to use the Set_Custom_Property built-in)


The character that simulates the carriage return is the | (alt+124)
You can place it in both label and tooltip properties.

On the image above, you can see the multi-line CheckBox label.

Here are its particular properties:

   Implementation Class : oracle.forms.fd.JCheckBoxMLline
   Label : Check|box
   Tooltip : CheckBox tooltip<params>fg=255,255,255 bg=120,120,255</params>


The parameters set in the tooltip property must be entered between the <params> and </params> tags.
The properties you can set are:

   the tooltip text color : fg=r,g,b
   the tooltip background color : bg=r,g,b[,r,g,b]
   the tooltip position : pos=x,y





The Java code

     src.zip



The implementation classes of the Bean Item

   There are as many classes as Forms item types:

Forms item Implementation Class property
Check Box item oracle.forms.fd.JCheckBoxMLline
Combo list oracle.forms.fd.JComboBoxMLline
T list oracle.forms.fd.JTListMLline
Pop list oracle.forms.fd.JPopListMLline
Radio button oracle.forms.fd.JRadioButtonMLline
Text item oracle.forms.fd.JTextFieldTooltip
Command button oracle.forms.fd.JVButtonMLline




The methods you can call


  • Set the tooltip text color

Set_Custom_Property( 'BL.BEAN', 1, 'SET_TEXT_COLOR', 'r,g,b' ) ;

  • Set the backgtound tooltip color

Set_Custom_Property( 'BL.BEAN', 1, 'SET_COLORS', 'r,g,b[,r,g,b]' ) ;

If you set two colors, the tooltip background will be colorized with a gradient from the first color to the second one.
e.g. :

// set background tooltip color gradient from red to yellow
Set_Custom_Property('BL.BEAN', 1, 'SET
_COLORS', '255,120,120,255,255,128' ) ;         


// set background tooltip color to light blue
Set_Custom_Property('BL.BEAN', 1, 'SET
_COLORS', '120,120,255' ) ;         

  • Set the tooltip absolute position

You can enforce the tooltip to be displayed on a particular position relative to the parent window (default) or the MDI window.
The X,Y coordinates are in pixel.

Set_Custom_Property( 'BL.BEAN', 1, 'SET_POSITION', '10,250' ) ;

  • Set the window attachment for absolute tooltip position

Set_Custom_Property( 'BL.BEAN', 1, 'SET_ATTACH', 'MDI | anything_else' ) ;

If you decide to use the absolute tooltip positionning (SET_POSITION) you can define if the tooltip is attached to its parent window (default) or to the MDI window



The sample dialog

     .
Download the multiline.zip file
     . Unzip the files
     . copy the
Multiline.jar file in the <ORACLE_HOME>/forms/java directory
     . Edit your /forms/server/formsweb.cfg file to add these 2 jar files
     . Open the
MULTILINE.fmb module (Oracle Forms 10.1.2)
   . Compile all and run the module

Repost 0
Published by Oracle Forms community - dans Bean - general
commenter cet article
26 décembre 2006 2 26 /12 /décembre /2006 17:46

Purpose

Here is a Java bean that allows to have an enhanced Web Browser.
It is a full Web browser that can handle Javascript and display Flash animations.

The material comes from a sourceforge project:
http://sourceforge.net/project/showfiles.php?group_id=170904


Enhanced Web Browser

It can accept both http url and local machine html file names.

It needs, at least, a 1.4 JRE so the Sun Java plug-in, so that it won't run with the JInitiator.


The Java code

     EnhancedHTMLBrowser.java



The implementation class of the Bean Item

     oracle.forms.fd.EnhancedHTMLBrowser


The methods you can call



  • Get the Forms Window

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

This must be used to retrieve the Forms window that handles the webBrowser, then synchronize its position when the windows is moved. This must be the first property set (in the When-New-Form-Instance trigger).

 

 

 

 

 

  • Set the URL/File

Set_Custom_Property( 'BL.BEAN', 1, 'SET_URL', 'url | file_name' ) ;


e.g. :

Set_Custom_Property('BL.BEAN', 1, 'SET_URL', 'http://www.developpez.com/' ) ;         


Set_Custom_Property('BL.BEAN', 1, 'SET_URL', 'd:/mypage.htm' ) ;

  • Set the border of the bean

Set_Custom_Property( 'BL.BEAN', 1, 'SET_BORDER', 'true | false' ) ;


When you want to use this bean to display a Flash image (*.swf), you would probably prefer not to have any border bounding the image.
In this case, set the border to false.


  • Basic navigation

Set_Custom_Property( 'BL.BEAN', 1, 'SET_NAVIGATION', 'back | forward | refresh' ) ;



The sample dialog

     .
Download the eHTMLBrowser.zip file
     . Download the sourceforge project zip file

     . Unzip the files
     . copy the jdic.jar and eHTMLBrowser.jar files in the <ORACLE_HOME>/forms/java directory

     . Edit your /forms/server/formsweb.cfg file to add these 2 jar files
     . Add the 2 .dll files and IeEmbed.exe (from the javaflashbridge-v1.zip file) to your Windows/system32 directory
     . Open the EHTMLBROWSER.fmb module (Oracle Forms 9.0.2)
     . Compile all and run the module

     The .jar files must be signed
     The eHTMLBrowser.jar and jdic.jar files provided with the .zip file are already signed


 

Repost 0
Published by Oracle Forms community - dans Bean - general
commenter cet article
22 décembre 2006 5 22 /12 /décembre /2006 10:04

Purpose

Here is a Java bean that allows to start programmes on the client machine, then capture the standard/error output.
It could be used if you don't want to install or use the Webutil library.


Java Host

If you target to use parameters that contain blanks, separate them by a comma.
The output lines are sent by the external programme (and received by Forms) asynchronously.



The Java code

     JavaHost.java



The implementation class of the Bean Item

     oracle.forms.fd.JavaHost


The methods you can call


 

  • Set the command

Set_Custom_Property( 'BL.BEAN', 1, 'SET_PROG', 'command' ) ;


e.g. :

Set_Custom_Property('BL.BEAN', 1, 'SET_PROG', 'cmd /c dir /b d:/*.jpg' ) ;         

If you intend to use parameters that contains blanks, use a comma to seperate them:

Set_Custom_Property('BL.BEAN', 1, 'SET_PROG', 'cmd,/c,findstr,"width height", d:/oracle9i/forms90/server/formsweb.cfg' ) ;


The event raised by the bean



 

  • MSGSTND

This event is raised by the bean to inform Forms that a line has been sent by the external process on the standard output.

 

  • MSGERROR

This event is raised by the bean to inform Forms that a line has been sent by the external process on the error output.


Here is the code of the When-Custom-Item-Event trigger of the sample dialog:

DECLARE
   
    eventName varchar2(30) := :system.custom_item_event;
    eventValues ParamList;
    eventValueType number;
    LC$Msg     Varchar2(32000);
    LC$Item    varchar2(256);
    LC$Event   varchar2(256);  
   
BEGIN
   
   IF (eventName='MSGSTND') THEN
      -- get the standard output --
      eventValues := get_parameter_list(:system.custom_item_event_parameters);
      get_parameter_attr(eventValues,'MSGTEXT',eventValueType, LC$Msg);
      If Length(:BL.RESULT) + Length(LC$Msg) > 32000 Then
       :BL.RESULT := '' ;
      End if ;
      :BL.RESULT := :BL.RESULT || LC$Msg || CHR(10) ;
      Synchronize;
   ELSIF (eventName='MSGERROR') THEN
      -- get the component properties --    
      eventValues := get_parameter_list(:system.custom_item_event_parameters);
      get_parameter_attr(eventValues,'MSGTEXT',eventValueType, LC$Msg);
      If Length(:BL.RESULT) + Length(LC$Msg) > 32000 Then
       :BL.RESULT := '' ;
      End if ;
      :BL.RESULT := :BL.RESULT || ' *** ERROR ***' || CHR(10) || LC$Msg || CHR(10) ;
      Synchronize;
   END IF;
   
END;


The sample dialog

     . Download the javahost.zip file

     . Unzip the file
     . copy the javahost.jar file in the <ORACLE_HOME>/forms/java directory

     . Edit your /forms/server/formsweb.cfg file to add this jar file
     . Open the JAVA_HOST.fmb module (Oracle Forms 9.0.2)
     . Compile all and run the module

     The .jar file must be signed
     The javahost.jar file provided with the .zip file is already signed


Repost 0
Published by Oracle Forms community - dans Bean - general
commenter cet article
10 décembre 2006 7 10 /12 /décembre /2006 15:39

Purpose

Here is a Java bean that allows to capture the mouse events and display the properties and methods of the clicked component.
In this second chapter, the bean is able to etablish the correspondance between the Java components and the Forms module's items.
When the mouse enter an item, the background color is changed, then an event is sent to Forms to indicate which item is concerned. The message indicates the Forms item name.

This demonstrates that you can get events from every item with a single Bean component.



Right-click on a component to display its properties and methods.


The Java code

     HandleMouseEvent2.java



The implementation class of the Bean Item


     oracle.forms.fd.HandleMouseEvent2


The methods you can call


    * Enable/disable mouse event capture

Set_Custom_Property('BLOCK.ITEM', 1, 'SETEVENT', 'parameter');

where parameter is:

   event name,boolean

e.g. :

Set_Custom_Property('BL.BEAN', 1, 'SETEVENT', 'PRESS=FALSE' ) ;
        

event name can be one of the following:

  - MOVE (mouse move)
  - EXIT (mouse exit)
  - PRESS (mouse button pressed)
  - REL (mouse button released)
  - ENTER (mouse enter)
  - CLICK (mouse click)

   By default, the MOVE event is disabled.

    * Enable/disable all mouse events

Set_Custom_Property('BLOCK.ITEM', 1, 'ALLOWEVENT', 'true|false');


    * Set the highlight mode

The highlight mode is used to colorize the item background when the mouse entered in it.

Set_Custom_Property('BLOCK.ITEM', 1, 'SETHIGLIGHT, 'mode');
where mode can be:

   - a positive value to brighter the current item background color
   - a negative value to darker the current item background color
   - a valid r,g,b value
   - false (to avoid automatic coloration)

  e.g.:

  -- darker --
  Set_Custom_Property('BL.BEAN', 1, 'SETHIGLIGHT', '-20' ) ;
  -- brighter --
  Set_Custom_Property('BL.BEAN', 1, 'SETHIGLIGHT', '20' ) ;
  -- special color --                                        
  Set_Custom_Property('BL.BEAN', 1, 'SETHIGLIGHT', '185,255,185' ) ;
  -- no highlight --                                        
  Set_Custom_Property('BL.BEAN', 1, 'SETHIGLIGHT', 'false' ) ;
  

    * Send the Forms item properties to the bean

Set_Custom_Property('BLOCK.ITEM', 1, 'SETPROP', 'properties');
where properties are:

   item name, X position on canvas, Y position on canvas

e.g.:

Set_Custom_Property( 'BL.BEAN', 1, 'SETPROP','BL.PBUTTON,40,30' ) ;

This last method is used to communicate the item coordinates to the Bean, so it can etablish the matching between the Java component and the Forms items.

It is used in the SetProperties() Forms procedure that scans the visible items of the form.


Note : the coordinates used by the java bean are pixel, so the Forms coordinate system must be set to pixel too.

If your coordinate system is different, here is a procedure that convert inches, points or centimeters to pixels:

Declare
   LC$Scoord VARCHAR2(100) := Get_Form_Property( Name_in('system.current_form'), COORDINATE_SYSTEM ) ;
Begin
   -- Convert to pixel --
   If LC$Scoord = 'INCHES' Then
      value := value * 0.0104 ;
   ElsIf LC$Scoord = 'POINTS' Then
      value := value * 1.333 ;
   ElsIf LC$Scoord = 'CENTIMETERS' Then
      value := value * 0.0263 ;
   End if ;
End ;



The event raised by the bean

    * SENDMSG

This event is raised by the bean to inform Forms that a mouse event has occured.
4 properties are provided:

  - MSGEVENT : event raised (mouse enter, exit, click, move, press)
  - MSGTYPE : type of the component ( e.g. oracle.forms.ui.VButton for a PushButton)
  - MSGITEM : class name of the component
  - MSGCOORD : coordinates of the mouse pointer
  - MSGBTMOUSE : mouse button number

  IF (eventName='SENDMSG') THEN
      -- get the mouse message --
      eventValues := get_parameter_list(:system.custom_item_event_parameters);
      get_parameter_attr(eventValues,'MSGEVENT',eventValueType, LC$Event);
      get_parameter_attr(eventValues,'MSGTYPE',eventValueType, LC$Type);
      get_parameter_attr(eventValues,'MSGITEM',eventValueType, LC$Item);
      get_parameter_attr(eventValues,'MSGCOORD',eventValueType, LC$Coord);
      get_parameter_attr(eventValues,'MSGBTMOUSE',eventValueType, LC$Button);
      LC$Msg := LC$Event
             || ' object=' || LC$Type
             || ' item=' || LC$Item           
             || ' at ' || LC$Coord
             || ' mouse=' || LC$Button ;
      clear_message;
      Message(LC$Msg, no_acknowledge) ;
      Synchronize ; 


    * SENDPROPS

This event is raised by the bean to inform Forms that the property and method information of the component has been sent.
In the sample dialog, this information is stored in a Text item, then displayed via the Edit_TextItem() Forms built-in.
It can be displayed by right-clicking on anywhere on the screen.




   ELSIF (eventName='SENDPROPS') THEN
      -- get the component properties --     
      eventValues := get_parameter_list(:system.custom_item_event_parameters);
      get_parameter_attr(eventValues,'MSGPROPS',eventValueType, LC$Msg);
      :BL.PROPERTIES := Replace(LC$Msg, '/n', CHR(10));
      Set_Custom_Property('BL.BEAN', 1, 'ALLOWEVENT', 'false' ) ;
      Go_Item('BL.PROPERTIES');
      edit_textitem ;
      Set_Custom_Property('BL.BEAN', 1, 'ALLOWEVENT', 'true' ) ;
   END IF;



The sample dialog

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


Using the JInitiator:

Tom Casserly provides, here, an equivalent that runs correctly with JInitiator.

Download the JInititator compatible version

Repost 0
Published by Oracle Forms community - dans Bean - general
commenter cet article
9 décembre 2006 6 09 /12 /décembre /2006 11:56
Purpose

Here is a Java bean that allows to capture the mouse events and display the properties and methods of the clicked component.

Mouse events

Right-click on a component to display its properties and methods.


The Java code

     HandleMouseEvent.java



The implementation class of the Bean Item

     oracle.forms.fd.HandleMouseEvent


The methods you can call


  • Enable/disable mouse event capture

Set_Custom_Property('BLOCK.ITEM', 1, 'SETEVENT', 'parameter');


where parameter is:

   event name,boolean

e.g. :

Set_Custom_Property('BL.BEAN', 1, 'SETEVENT', 'PRESS=FALSE' ) ;         

event name can be one of the following:

  - MOVE (mouse move)
  - EXIT (mouse exit)
  - PRESS (mouse button pressed)
  - REL (mouse button released)
  - ENTER (mouse enter)
  - CLICK (mouse click)


   By default, the MOVE event is disabled.

  • Enable/disable all mouse events

Set_Custom_Property('BLOCK.ITEM', 1, 'ALLOWEVENT', 'true|false');


The event raised by the bean

  • SENDMSG

This event is raised by the bean to inform Forms that a mouse event has occured.
4 properties are provided:

  - MSGEVENT : event raised (mouse enter, exit, click, move, press)
  - MSGITEM : class name of the component
  - MSGCOORD : coordinates of the mouse pointer
  - MSGBTMOUSE : mouse button number

  IF (eventName='SENDMSG') THEN
      -- get the mouse message --
      eventValues := get_parameter_list(:system.custom_item_event_parameters);
      get_parameter_attr(eventValues,'MSGEVENT',eventValueType, LC$Event);
      get_parameter_attr(eventValues,'MSGITEM',eventValueType, LC$Item);
      get_parameter_attr(eventValues,'MSGCOORD',eventValueType, LC$Coord);
      get_parameter_attr(eventValues,'MSGBTMOUSE',eventValueType, LC$Button);
      LC$Msg := LC$Event
             || ' object=' || LC$Item
             || ' at ' || LC$Coord
             || ' mouse=' || LC$Button ;
      clear_message;
      Message(LC$Msg, no_acknowledge) ;
      Synchronize ; 


  • SENDPROPS

This event is raised by the bean to inform Forms that the property and method information of the component has been sent.
In the sample dialog, this information is stored in a Text item, then displayed via the Edit_TextItem() Forms built-in.
It can be displayed by right-clicking on anywhere on the screen.

Mouse events


   ELSIF (eventName='SENDPROPS') THEN
      -- get the component properties --      
      eventValues := get_parameter_list(:system.custom_item_event_parameters);
      get_parameter_attr(eventValues,'MSGPROPS',eventValueType, LC$Msg);
      :BL.PROPERTIES := Replace(LC$Msg, '/n', CHR(10));
      Set_Custom_Property('BL.BEAN', 1, 'ALLOWEVENT', 'false' ) ;
      Go_Item('BL.PROPERTIES');
      edit_textitem ;
      Set_Custom_Property('BL.BEAN', 1, 'ALLOWEVENT', 'true' ) ;
   END IF;



The sample dialog

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

Repost 0
Published by Oracle Forms community - dans Bean - general
commenter cet article
28 novembre 2006 2 28 /11 /novembre /2006 13:17

Purpose

Here is a Java bean that allows to send emails with html body and attachments.
It is a modified version of the Oracle Forms Demo's  javamail bean.


javamail

The javamail Oracle Forms Demo allows to send emails with attachments located on the server side.
This one is executed on the local machine, can send emails with html body and attachments from the local machine.

It needs the JavaMail(TM) API 1.4 release, so it can't run under JInitiator. You need to run the Sun Java Plug-in.



The Java code

     Sendmail.java     SendMessageException.java.java



The implementation class of the Bean Item

     oracle.forms.fd.SendMail


The methods you can call


  • Set the SMTP authentication

Set_Custom_Property('BLOCK.ITEM', 1, 'SET_MAIL_AUTHENTICATION', 'username,password');


If you provide authentication, this method must called first.


  • Set the mail parts 

Set_Custom_Property('BLOCK.ITEM', 1, 'SET_MAIL_INFOS', 'infos');


where infos are:

smtp addess | From | To | Subject | Body | attachment

e.g. :

 LC$Infos := :MAIL.SMTP_SERVER || '|'
           || :MAIL.FROM || '|'
           || :MAIL.TO || '|'
           || :MAIL.SUBJECT || '|'
           || :MAIL.BODY || '|'
           || :MAIL.ATTACHMENTS ;
          
  Set_Custom_Property( 'CONTROL.MAIL', 1, 'SET_MAIL_INFOS', LC$Infos ) ;
    

Each attached file in the list is separated with a coma.


Java security indication:

You have to update the .../Java/jre1.X.XX/lib/security/java.policy file to grant security permission

 permission java.security.AllPermission;


This bean need the mail.jar and activation.jar files wich are part of the JavaMail(TM) API 1.4 release
(these 2 jar files are provided with the zip file with this article)


The sample dialog

     . Download the javamail.zip file
     . Unzip the file
     . copy the mail.jar, activation.jar and SendMail.jar file in the <ORACLE_HOME>/forms/java directory
     . Edit your /forms/server/formsweb.cfg file to add these 3 jar files
     . Open the javamail.fmb module (Oracle Forms 9.0.2)
     . Compile all and run the module

Repost 0
Published by Oracle Forms community - dans Bean - general
commenter cet article
6 novembre 2006 1 06 /11 /novembre /2006 10:42

Purpose

Here is a Java bean that allows to chat on a Forms application


Chat on Forms

It uses a modified version of the socketserver sample.
The list of chatters is held by a database table (CHAT) and a database package (PKG_CHAT) that get and dispatch the messages from/to the connected users.

REM Create the CHAT table
CREATE TABLE CHAT
(
  IP_ADDRESS VARCHAR2(15 BYTE),
  PORT       NUMBER(5,0),
  NAME       VARCHAR2(100 BYTE),
  FIRST_CONN DATE
)
/


The sample dialog provided with the bean allows to test the chat system.
When a chatter just connects, you can see his/her name in the chatter list.
Check the check-box if you want he/she receives your messages.
In the To send text box, use the Tab key to send the message.


The Java code

     ChatClient.java     ChatServer.java



The implementation class of the Bean Item

    oracle.forms.fd.ChatClient


The methods you can call


  • Init the socket server

Set_Custom_Property('BLOCK.ITEM', 1, 'INIT_SERVER', 'port_number');


e.g. :
Set_Custom_Property( 'BL.BEAN', 1, 'INIT_SERVER', '4450' ) ;
   


  • Stop the socket server


Set_Custom_Property('BLOCK.ITEM', 1, 'STOP_SERVER', '');

e.g. :
Set_Custom_Property( 'BL.BEAN', 1, 'STOP_SERVER', '' ) ;
   



The event received from the Bean

  • SENDMSG

this event tells Forms that a message is sent by the Java Bean.
You can get it in a WHEN-CUSTOM-ITEM-EVENT event:

DECLARE
   
    eventName varchar2(30) := :system.custom_item_event;
    eventValues ParamList;
    eventValueType number;
    LC$Msg    varchar2(32000);
    LC$Value  varchar2(256);
   
BEGIN
   
   IF (eventName='SENDMSG') THEN
      eventValues := get_parameter_list(:system.custom_item_event_parameters);
      get_parameter_attr(eventValues,'MESSAGEVALUE',eventValueType, LC$Msg);
      -- Socket Server OK --
      If LC$Msg = '[SocketServerOK]' Then
        Set_Item_Property( 'BL.START', LABEL, 'Disconnect' ) ;
        :BL.STATUS := 'Connected on port ' || :BL.PORT  || CHR(10) || :BL.STATUS;
        Pkg_Chat.Open_Connexion( :BL.IP, :BL.PORT, :BL.NAME);
      -- new connexion --
      ElsIf Instr( LC$Msg, '[conn]' ) > 0 Then
        bell ;
        Query_Users ;
        :BL.STATUS := 'Connection of ' || Replace(LC$Msg,'[conn]','' )  || CHR(10) || :BL.STATUS;
      -- Deconnexion --
      ElsIf Instr( LC$Msg, '[deconn]' ) > 0 Then
        bell ;
        :BL.STATUS := 'Disconnection of ' || Replace(LC$Msg,'[deconn]','' )  || CHR(10) || :BL.STATUS;
        Query_Users ;
      -- Standard message --
      Else
         Add_Text( Replace(LC$Msg,'^',CHR(10)) ) ;
      End if ;
      Synchronize ;           
   END IF;
   
END;


The sample dialog

     . Download the chat.zip file
     . Unzip the file
     . run the chat.sql script on your database (the Oracle user must have access to the UTL_TCP package)
     . copy the chat.jar file in the <ORACLE_HOME>/forms/java directory
     . Edit your /forms/server/formsweb.cfg file
     . Open the CHAT.fmb module (Oracle Forms 9.0.2)
     . Compile all and run the module

     the jar file must be signed.
     the jar file provided in this article is already signed.

Repost 0
Published by Oracle Forms community - dans Bean - general
commenter cet article
14 octobre 2006 6 14 /10 /octobre /2006 19:36

Purpose

Here is a Java bean that allows to transform a Forms module into a socket server.

This way, it can receive messages from the outside.
- In this example, the messages are sent through a telnet session.


Forms Socket Server

In this sample dialog, I have opened a telnet session:

   open localhost 4450

Then I can send messages to the Forms application.


- In another way, messages can also be sent by the database:

DECLARE
  c  utl_tcp.connection;  -- TCP/IP connection to the Socket server
  ret_val PLS_INTEGER;
BEGIN
  c := utl_tcp.open_connection(remote_host => '10.40.40.40',
                               remote_port =>  4450);  -- open connection
  ret_val := utl_tcp.write_line(c, 'Incoming Message Send by my Oracle DB');
  utl_tcp.close_connection(c);
END;



The Java code

     SocketServer.java     Server.java  



The implementation class of the Bean Item

     oracle.forms.fd.SocketServer


The methods you can call


Init the socket server

Set_Custom_Property('BLOCK.ITEM', 1, 'INIT_SERVER', 'port_number');

e.g. :
Set_Custom_Property( 'BL.BEAN', 1, 'INIT_SERVER', '4450' ) ;
   
 

The event received from the Bean

SENDMSG


this event tells Forms that a message is sent by the Java Bean.
You can get it in a WHEN-CUSTOM-ITEM-EVENT event:

DECLARE
   
    eventName varchar2(30) := :system.custom_item_event;
    eventValues ParamList;
    eventValueType number;
    LC$Msg    varchar2(512);
    LC$Value  varchar2(256);
   
BEGIN
   
   IF (eventName='SENDMSG') THEN
      eventValues := get_parameter_list(:system.custom_item_event_parameters);
      get_parameter_attr(eventValues,'MESSAGEVALUE',eventValueType, LC$Msg);
      -- Display the message --
      :BL.MSGS := :BL.MSGS || LC$Msg || Chr(10) ;
      Synchronize ;           
   END IF;
   
END;


The sample dialog

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

     the jar file must be signed.
     the jar file provided in this article is already signed.
Repost 0
Published by Oracle Forms community - dans Bean - general
commenter cet article