Send message to Forms from the outside ? yes you can !
By francois degrelle on Friday, March 27 2015, 15:01 - PJC - Javabean - Permalink
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.
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
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.