Overblog Tous les blogs Top blogs Technologie & Science Tous les blogs Technologie & Science
Editer l'article Suivre ce blog Administration + Créer mon blog
MENU

This is a bunch of tips and techniques related to Oracle PL/SQL and Forms.

Publicité

An "auto completion" Java Bean

Purpose

Here is a Java Bean that allows to manage an "auto completion" Swing JComboBox.



Key Pressed



The Java code

     CBAutoCompletion.java     ComboBoxCompletion.java



The implementation class of the Bean Item

     oracle.forms.fd.ComboBoxCompletion


 

The methods you can set



Init the ComboBox values

-- Single value list --
Get_Custom_Property('BLOCK.ITEM',1,'
INIT','value[,value[,...]]');


e.g.:
-- initialise the ComboBox values --
Set_Custom_Property('BL.BEAN',1,'INIT','Ester,Jordi,Jordina,Jorge,Sergi');  
 


-- Twin value list (code+value) --

Get_Custom_Property('BLOCK.ITEM',1,'
INIT_TWIN','code,value[,code,value[,...]]');
code(stored value) is provided, then after value (displayed)


e.g.:
-- initialise the ComboBox values --
Set_Custom_Property('BL.BEAN',1,'INIT_TWIN','v1,Ester,v2,Jordi,v3,Jordina,v4,Jorge,v5,Sergi');


This method must be the first called.

If you need to incorporate NULL values in the list, use the equivalent INIT_NULL and INIT_TWIN_NULL methods.

To set the focus on the NULL value, use the SELECT_INDEX,'1' or SELECT_CODE,'' methods.

If the amount of data to transfer is greater than 4000 bytes, replace the INIT[_NULL] or INIT_TWIN[_NULL] methods by the equivalent ADD[_NULL] of ADD_TWIN[_NULL]:

 

  Set_Custom_Property('BL.BEAN',1,'CLEAR','');
  Set_Custom_Property('BL.BEAN',1,'ADD_TWIN','v1,Ester,v2,Jordi,v3,Jordina');
  Set_Custom_Property('BL.BEAN',1,'ADD_TWIN','v4,Jorge,v5,Sergi,v6,Theodor');
  Set_Custom_Property('BL.BEAN',1,'ADD_TWIN','......');
  Set_Custom_Property('BL.BEAN',1,'ADD_TWIN','[END_DATA]');

 

In this case, the last call to ADD_XXX methods must contains the [END_DATA] string.

 

 

 

Set the Font

Get_Custom_Property('BLOCK.ITEM',1,'SET_FONT','font_name[,font_weight[,font_size]]);

font_weight could be one of the following:


P  : Plain
B  : Bold
I : Italic
BI : Bold+Italic


e.g.:
-- set the font --
Set_Custom_Property('BL.BEAN',1,'SET_FONT','Arial,B,12');
 



Enable/disable the combobox

Get_Custom_Property('BLOCK.ITEM',1,'SET_ENABLED','true | false');


e.g.:
-- disable the ComboBox --
Set_Custom_Property('BL.BEAN',1,'SET_ENABLED,'false'); 
 

 


Show/hide the ComboBox values

Get_Custom_Property('BLOCK.ITEM',1,'SET_VISIBLE','true | false');


e.g.:
-- hide the ComboBox --
Set_Custom_Property('BL.BEAN',1,'SET_VISIBLE,'false'); 
 

 

 

Set the starting index (by position)

Get_Custom_Property('BLOCK.ITEM',1,'SELECT_INDEX','index_num');


e.g.:
-- set focus on the 3rd option --
Set_Custom_Property('BL.BEAN',1,'SELECT_INDEX','3'); 
 

 

Set the starting index (by code)

Get_Custom_Property('BLOCK.ITEM',1,'SELECT_CODE','code');


e.g.:
-- set focus on the 3rd option --
Set_Custom_Property('BL.BEAN',1,'SELECT_CODE','v2'); 
 

 

Set the starting index (by value) twin value list only

Get_Custom_Property('BLOCK.ITEM',1,'SELECT_VALUE','value);


e.g.:
-- set focus on the 3rd option --
Set_Custom_Property('BL.BEAN',1,'SELECT_VALUE','Jordi'); 
 

 

 

The event raised by the bean

SELECTION_CHANGED

Each time the end user change the current value of the combobox, a message is send to Forms.

You can get this message in the When-Custom-Item-Event trigger of the Bean Item:
The index number is read from the SELECTION_INDEX list parameter
The code is read from the SELECTION_CODE list parameter
The value is read from the SELECTION_VALUE list parameter

 

DECLARE
    eventName varchar2(30) := :system.custom_item_event;
    eventValues ParamList;
    eventValueType number;
    LC$Index  varchar2(10);
    LC$Code  varchar2(1000);
    LC$Value  varchar2(1000);
BEGIN
   IF (eventName='SELECTION_CHANGED') THEN
      eventValues := get_parameter_list(:system.custom_item_event_parameters);
      get_parameter_attr(eventValues,'SELECTION_INDEX',eventValueType, LC$Index);
      get_parameter_attr(eventValues,'SELECTION_Code',eventValueType, LC$Code);
      get_parameter_attr(eventValues,'SELECTION_VALUE',eventValueType, LC$Value);
    
      -- display the current selction --
      :BL.SELECT := '[' || LC$Index || '] (' || LC$Code || ') ' || LC$Value ;

   END IF;
END;

 

 




The sample dialog


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

     The JAR file has to be signed.

 

Publicité
Retour à l'accueil
Partager cet article
Repost0
Pour être informé des derniers articles, inscrivez vous :
Commenter cet article
K
couldn't use it. why nit signed. please sign it as other java beans in this page
Répondre
F
<br /> I am using your bean its work perfect for less value (populate from database) but then the values are large then it cause problem,i tested the bean with 15000 employee name and its give<br /> exceptiion.<br /> <br /> <br /> Kindly advice.<br /> <br /> <br />  <br />
Répondre
O
<br /> <br /> Thanks. Sorry but I have no crystal ball and cannot guess what the exact exeption message is.<br /> <br /> <br /> <br />
P
<br /> It works in 11g !<br /> <br /> <br />  <br /> <br /> <br /> Thanks.<br /> <br /> <br />  <br /> <br /> <br /> PS: don't forget to import the jars : jewt4.jar,share.jar in your Jdev project and add the jars in Forms Server classpath (in Archive section).<br />
Répondre
P
<br /> Hello, can we change the button lookandfeel ?  I would like to have it like Oracle Look and feel and colorscheme Swan. <br /> <br /> <br />  <br /> <br /> <br /> Thanks<br /> <br /> <br />  <br />
Répondre
O
<br /> <br /> As it is written, the short answer is NO. But I imagine you could have a standard Forms look by importing the oracle.bali.ewt.olaf.OracleLookAndFeel class. It should work.<br /> <br /> <br /> <br />
A
<br /> <br /> It is very good, and i tried it and it is working fine,<br /> <br /> <br /> My concern is that is i want to use some query then how can use it to fetch the calues from some table?<br /> <br /> <br /> Thanks and Regards<br /> <br /> <br /> Abbas<br /> <br /> <br />  <br /> <br /> <br /> <br />
Répondre
O
<br /> <br /> Did you study the sample dialog shipped with the article ? It shows how to populate the Combo.<br /> <br /> <br /> <br />