Overblog
Editer l'article Suivre ce blog Administration + Créer mon blog
21 décembre 2007 5 21 /12 /décembre /2007 13:14

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

Partager cet article
Repost0

commentaires

B
Did anybody try to change jcalendar-1.3.2.jar with jcalendar-1.4.jar? Form compiles ok, but when I run it, I get error message:<br /> java.lang.NoClassDefFoundError: com/toedter/calendar/JCalendar<br /> at java.lang.Class.forName0(Native Method)<br /> at java.lang.Class.forName(Unknown Source)<br /> at oracle.forms.handler.UICommon.instantiate(Unknown Source)<br /> at oracle.forms.handler.UICommon.onCreate(Unknown Source)<br /> at oracle.forms.handler.JavaContainer.onCreate(Unknown Source)<br /> at oracle.forms.engine.Runform.onCreateHandler(Unknown Source)<br /> at oracle.forms.engine.Runform.processMessage(Unknown Source)<br /> at oracle.forms.engine.Runform.processSet(Unknown Source)<br /> at oracle.forms.engine.Runform.onMessageReal(Unknown Source)<br /> at oracle.forms.engine.Runform.onMessage(Unknown Source)<br /> at oracle.forms.engine.Runform.sendInitialMessage(Unknown Source)<br /> at oracle.forms.engine.Runform.startRunform(Unknown Source)<br /> at oracle.forms.engine.Main.createRunform(Unknown Source)<br /> at oracle.forms.engine.Main.start(Unknown Source)<br /> at com.sun.deploy.uitoolkit.impl.awt.AWTAppletAdapter.start(Unknown Source)<br /> at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)<br /> at java.lang.Thread.run(Unknown Source)<br /> <br /> And form does not open.<br /> Regards,<br /> Bojan
Répondre
M
This short article posted only at the web site is truly good.
Répondre
M
I am having trouble running this in Netbeans, how do i do this? Any help would be greatly appreciated.
Répondre
P
nedd class file of JCalendar.java<br /> file.when i compile it is giving error.i am using xp os and java 1.6
Répondre
S
I also need class file of Jcalendar.java<br /> forms date clicked shows calendar but on java date nothing happens no calendar is seen
M
<br /> <br /> So far I have no problem with java-plugin version. I use https and your Roguelle signed FJCalendar.jar. No problem.<br /> <br /> <br /> The only problem I have is the Jinit version. Do I have to change the implementation version in the form to execute the proper containter Jacalendar_Jinit?<br /> <br /> <br />  <br /> <br /> <br /> <br />
Répondre
O
<br /> <br /> As it is indicated at the end of the article, the Implementation Class for the JInitiator version is : oracle.forms.fd.JCalendarJinit<br /> <br /> <br /> <br /> <br /> <br /> <br />