Overblog Suivre ce blog
Editer l'article Administration Créer mon blog
25 janvier 2008 5 25 /01 /janvier /2008 11:13


Here is a Java Bean that allows sending back to the Forms application each key pressed in any Text Item.

Key Pressed

The Java code


The implementation class of the Bean Item


The methods you can call

Initialize the bean


This method must be called in the When-New-Form-Instance. It is used to search for every Text Items in the Forms to attach to them a key listener.

-- Init the bean --
Set_Custom_Property( 'BL.BEAN', 1, 'INIT', '' ) ;


The event fired by the JavaBean


It is constituted by 3 parameters to get the key code, the key char and the key modifier.

To know what text item has just fired the event, ask the :SYSTEM.CURSOR_ITEM variable.


    eventName varchar2(30) := :system.custom_item_event;
    eventValues ParamList;
    eventValueType number;
    LC$Code   varchar2(25); -- code
    LC$Char   varchar2(25); -- char
    LC$Modif  varchar2(25); -- modifier

   IF (eventName='KEY_PRESSED') THEN
      eventValues := get_parameter_list(:system.custom_item_event_parameters);
      get_parameter_attr(eventValues,'KEY_CODE',eventValueType, LC$Code);
      get_parameter_attr(eventValues,'KEY_CHAR',eventValueType, LC$Char);
      get_parameter_attr(eventValues,'KEY_MODIFIER',eventValueType,  LC$Modif);
      :BL.RESULT := :System.cursor_item || ' Key pressed:'|| LC$Code || ' (' || LC$Char||') '||' modif:'||LC$Modif ;
      Synchronize ;

   END IF; 

The sample dialog

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

Partager cet article

Repost 0
Published by Oracle Forms community - dans Bean - Text items
commenter cet article