Overblog
Suivre ce blog
Editer l'article Administration Créer mon blog
6 février 2008 3 06 /02 /février /2008 11:34

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.

 

Partager cet article

Published by Oracle Forms community - dans Bean - general
commenter cet article

commentaires

Fahed Akhter 28/07/2013 05:03


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
exceptiion.


Kindly advice.


 

Oracle Forms community 13/08/2013 09:18



Thanks. Sorry but I have no crystal ball and cannot guess what the exact exeption message is.



Philippe Hubert 31/10/2012 08:48


It works in 11g !


 


Thanks.


 


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).

Philippe Hubert 30/10/2012 10:54


Hello, can we change the button lookandfeel ?  I would like to have it like Oracle Look and feel and colorscheme Swan. 


 


Thanks


 

Oracle Forms community 31/10/2012 06:40



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.



Abbas 04/08/2011 08:52



It is very good, and i tried it and it is working fine,


My concern is that is i want to use some query then how can use it to fetch the calues from some table?


Thanks and Regards


Abbas


 



Oracle Forms community 04/08/2011 19:50



Did you study the sample dialog shipped with the article ? It shows how to populate the Combo.



Samit 07/01/2009 08:05

I try but its not working for me. I want this feature immediately. Please give step by step process pls. I m new in the forms 10g.

Oracle Forms community 07/01/2009 10:13


"...I try but its not working for me..."
You know that this great information won't help anybody to solve any problem.
All the required steps are explained in the article, so copy the JAR file in your /forms/java directory, and add it to the archive and archive_jini tags of the
/forms/server/formsweb.cfg file.
Open the sample dialog shipped with the zip file then run it. At runtime, display the Java console to see if any messages are raised.