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.



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.