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',1ET_PROPERTY','plasticLAF,true');
Set_Custom_Property('BL.BEAN',1ET_PROPERTY','log,true');
Set_Custom_Property('BL.BEAN',1ET_PROPERTY','title,Choose...');
Set_Custom_Property('BL.BEAN',1ET_PROPERTY','locale,US');
Set_Custom_Property('BL.BEAN',1ET_PROPERTY','foreground,r128g50b50');

Set_Custom_Property('BL.BEAN',1ET_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',1HOW_CALENDAR','');

-- show calendar at position 50,50 --
Set_Custom_Property('BL.BEAN',1HOW_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