Vendredi 21 décembre 2007

Purpose

Here is a Java bean that allows to choose a date from a Java swing calendar.

The Java calendar itself is from Kai Toedter - Released under GNU Lesser General Public License - www.toedter.com

It needs the Sun Java plugin to run (won't run with JInitiator).

(the JInitiator 1.3.28 compatible version is downlodable at the end of the article)



JCalendar

Just double-click a day in the calendar to send an event to Forms with the date parameters.



The Java code

     JCalendar.java



The implementation class of the Bean Item

     oracle.forms.fd.JCalendar


The properties you can set



Set some properties

Set_Custom_Property('BL.BEAN', 1, 'SET_PROPERTY', 'property_name,property_value');

property_name can be one of the following:

  • title : set the frame title
  • background : set the background color
  • foreground : set the foreground color
  • decorationforeground : set the decoration foreground color (Sun plugin only)
  • sundayforeground : set the sunday foreground color (Sun plugin only)
  • weekdayforeground : set the week day foreground color (Sun plugin only)
  • date : set the starting date (year,month,day) (Sun plugin only)
  • locale : set a new Locale
  • plasticLAF : set the PlasticLAF Look & Feel
  • log : set the trace to the Java console (true | false)

colors are sent with the following format : rXgXbX where x must be between 0 and 255

e.g. :
Set_Custom_Property('BL.BEAN',1, 'SET_PROPERTY','plasticLAF,true');
Set_Custom_Property('BL.BEAN',1, 'SET_PROPERTY','log,true');
Set_Custom_Property('BL.BEAN',1, 'SET_PROPERTY','title,Choose...');
Set_Custom_Property('BL.BEAN',1, 'SET_PROPERTY','locale,US');
Set_Custom_Property('BL.BEAN',1, 'SET_PROPERTY','foreground,r128g50b50');

Set_Custom_Property('BL.BEAN',1, 'SET_PROPERTY','date,2007,12,25');


Show the calendar


Set_Custom_Property('BL.BEAN', 1, 'SHOW_CALENDAR', '[x_position,y_position]');

 

 

If x_position and y_position are given, the calendar will be shown at this position (top-left corner).

e.g:
-- show calendar --
Set_Custom_Property('BL.BEAN',1, 'SHOW_CALENDAR','');

-- show calendar at position 50,50 --
Set_Custom_Property('BL.BEAN',1, 'SHOW_CALENDAR','50,50');

 

The event received from the Bean

CALENDAR_EVENT


this event tells Forms that a date has been chosen in the calendar.
You can get it in a WHEN-CUSTOM-ITEM-EVENT event:

DECLARE
   
    eventName varchar2(30) := :system.custom_item_event;
    eventValues ParamList;
    eventValueType number;
    LC$Date   varchar2(256); -- complete date
    LC$Day    varchar2(256); -- day number (1-31)
    LC$Month  varchar2(256); -- month number (1-12)
    LC$Year   varchar2(256); -- year number
   
BEGIN
   
   IF (eventName='CALENDAR_EVENT') THEN
      eventValues := get_parameter_list(:system.custom_item_event_parameters);
      get_parameter_attr(eventValues,'CALENDAR_EVENT_DATE',eventValueType, LC$Date);
      get_parameter_attr(eventValues,'CALENDAR_EVENT_DAY',eventValueType, LC$Day);
      get_parameter_attr(eventValues,'CALENDAR_EVENT_MONTH',eventValueType, LC$Month);
      get_parameter_attr(eventValues,'CALENDAR_EVENT_YEAR',eventValueType, LC$Year);
      Clear_Message;
      Message('Selected date:'|| LC$Date || '(' || LC$Day||'/'||LC$Month||'/'||LC$Year || ')');
      Synchronize ;           
   END IF;  
   
END;



The sample dialog

     . Download the JCalendar.zip file
     . Unzip the file
     . copy the FJCalendar.jar, jcalendar-1.3.2.jar and looks-2.0.1.jar files in the <ORACLE_HOME>/forms/java directory
     . Edit your /forms/server/formsweb.cfg file to add these 3 JAR files
     . Open the JCALENDAR.fmb module (Oracle Forms 9.0.2)
     . Compile all and run the module

     the FJCalendar.jar file must be signed.
     the jar file provided in this article is already signed.


Jinitiator 1.3.28 compatible version

     . Download the JCalendarJinit.zip file
     . Unzip the file
     . copy the JCalendarJinit.jar and jcalendar.jar files in the <ORACLE_HOME>/forms/java directory
     . Edit your /forms/server/formsweb.cfg file to add these 2 JAR files

     . The Implementation Class property must be : oracle.forms.fd.JCalendarJinit

par Oracle Forms community publié dans : Bean - general
ajouter un commentaire commentaires (6)    recommander

Commentaires

disulpe, soy novato en forms, al hacer el ejemplo de su pagina me sale un error que dice que "No se ha encontrado en JavaBean con el nombre 'oracle.forms.fd" y pues no e podido hacer nada. Le agradeceria cualquier ayuda, gracias
commentaire n° : 1 posté par : max le: 28/12/2007 23:17:00
No comprendo español.
réponse de : Oracle Forms community (site web) le: 29/12/2007 08:59:11
I'm affraid this doesn't work for me... I copied FJCalendar.jar, jcalendar-1.3.2.jar and looks-2.0.1.jar files to the /forms/java directory. I added these jars to archive_init section of formsweb.cfg file, but every time I start forms it throws message that it cannot find javabean named oracle.forms.fd.JCalendar Am i doing something wrong or did i miss something...? Please help me...
commentaire n° : 2 posté par : ja le: 13/02/2008 12:15:18
If you are using the JInitiator, read attentively what you have to do at the bottom of the article. The JAR files to use are not the same.
réponse de : Oracle Forms community (site web) le: 13/02/2008 13:45:25
For Sun pluging you mast add jar names to 'archive' line, not 'archive_jinit'.
Demo form works fine with Sun plugin, althoug if you just click on 'Close Form' icon, the form goes away but calendar stays :)
commentaire n° : 3 posté par : Stan le: 05/05/2008 18:17:20

Thanks, I will change this  ;D


réponse de : Oracle Forms community (site web) le: 06/05/2008 07:48:55
Why didn't you add something like 

else if(sProp.equalsIgnoreCase("locale")) {
String sLang = s1 ;
if(sLang.equalsIgnoreCase("US"))locale = Locale.US ;
else if(sLang.equalsIgnoreCase("CANADA"))locale = Locale.CANADA ;
else if(sLang.equalsIgnoreCase("CANADA_FRENCH"))locale = Locale.CANADA_FRENCH;
else if(sLang.equalsIgnoreCase("CHINA"))locale = Locale.CHINA;
.
.
.
else locale= new Locale(sLang);

for us who don't live in any of these countries you provided , and yould you, please, add this ?
commentaire n° : 4 posté par : Me le: 13/05/2008 12:34:32
Done.
I tested it with the following:
Set_Custom_Property('BL.BEAN',1, 'SET_PROPERTY','locale,el|Greece');
Because the 1.3 syntax needs both language and country, you have to seperate them with a alt-124 (|) character.
réponse de : Oracle Forms community (site web) le: 13/05/2008 14:37:43
Great, man, thank you!
commentaire n° : 5 posté par : Me le: 14/05/2008 09:41:26
Hi.I try the demo and its work fine. But i have a problem, I have a forms when its running another javaBean, this forms call JCALENDAR using OPEN_FORM, then when i press the button to see the calendar nothing happens. SET_CUSTOM_PROPERTY('BL.BEAN',1,'SHOW_CALENDAR',''); dont work.  Can you help me?
commentaire n° : 6 posté par : jreyesvil le: 27/06/2008 03:02:33

I am unable to reproduced. I have added a push button to the JCALENDAR.FMB sample dialog provided with the article, then added an Open_Form() of itself in the When-Button-Pressed trigger. I can
show the Swing calendar in both the forms.


réponse de : Oracle Forms community (site web) le: 27/06/2008 07:35:00
Blog : Musique sur over-blog.com - Contact - C.G.U. - Rémunération en droits d'auteur avec TF1 Network - Signaler un abus