Calendar PJC Information

The Calendar Pluggable Java Component (PJC) provides a popup calendar widget that the user can use to select a date from. The PJC itself is represented as a button on the Form, that automatically pops up the selection window when it is pressed.  This PJC actually calls another JavaBean to display the calendar and is an example of how you can integrate a pre-existing Bean into Forms using the PJC mechanism.

Modules In This Demo

The Calendar PJC demo consists of the following files (relative directories shown in brackets):

  1. calendarpjc.fmb/fmx [forms]- The demo form
  2. *.java [src/oracle/forms/demos] - source code for the Calendar Bean and PJC wrapper code
  3. calendar.jar [classes]- the compiled and jarred java classes.

The doc directory and the classes directory contain the JavaDoc for the code and the compiled classes respectively

Reusing the code

Setting up Forms Services

In order for an application to be able to use the Calendar PJC the relevant configuration in the formsweb.cfg file has to ensure that the supplied calendar.jar (or another jar file containing the compiled classes) is included in the relevant archive setting.

An entry in the formsweb.cfg file for an application that used the Calendar PJC  might look like this:

[CalendarPJC]
pageTitle=OracleAS Forms Services - Calendar PJC Demo
IE=jinitiator
baseHTMLJInitiator=demobasejini.html
archive_jini=frmall_jinit.jar,calendar.jar
form=calendarpjcforms/java
width=675
height=480
separateFrame=false
splashScreen=no
lookAndFeel=oracle
colorScheme=blue
background=/formsdemo/images/blue.gif

Using the PJC in your Form

To use the Calendar PJC you must first create a normal Forms bean area. 

Then set the Implementation Class property for this list item to oracle.forms.demos.CalendarWidgetWrapper.  Note that this property is case sensitive and must be entered exactly as shown.  At runtime, this Bean will render as a simple button which the user can press to display the calendar

Setting Properties on the PJC

The Calendar supports custom properties for setting the label of the launch button, and the initial date to display in the popup window.  For instance the code to set the launch button label to "Get Date" would be: 

 SET_CUSTOM_PROPERTY('PJC.CALENDAR',1,'BUTTONLABEL','Get Date');

The first argument to Set_Custom_Property() is the name or id of the PJC enabled item.  The second parameter defines the instance of the control that you wish to set the property on.  This index number is one based and represents the physical control in the user interface (rather than the record number in the underlying block). You can use the constant ALL_ROWS to set the property on all instances of the PJC for this field.  The third argument is the custom property that is being set on the PJC and the forth the value.

The property setDate is used to set the initial date for display.  The date is expected in the format DD.MM.YYYY

Getting the Selected Date from the  PJC

When the user selects a date in the PJC and Custom Item event is sent back to the Form which should be handled in a WHEN-CUSTOM-ITEM-EVENT trigger associated with the PJC bean area.

The event sent back from the PJC will be called DateChange and has a parameter DateValue which contains the selected date a sample When-Custom-Item-Event to return this value into a date field would:

Declare
  paramType number;
  newDate
Val 

varchar2(80);
  newDate date := null;
begin
  if(:system.custom_item_event = 'DateChange') then
    get_parameter_attr(:system.custom_item_event_parameters, 'DateValue', ParamType, newDateVal);
    newDate := to_date(newDateVal,'DD.MM.YYYY');
  end if
  :EMP.HIREDATE := newDate;
end;

Custom Property Summary

Property Get Set Valid Values / Return Value Purpose
BUTTONLABEL No Yes String Label to display on the launch button
setDate No Yes String Date to initialize the Calendar with.