The KeyFilter Pluggable Java Component (PJC) provides an example of enhancing a normal Forms text item with the ability to both filter the keystrokes that the user enters into the item, and to obtain information about the keys that the user has actually pressed. The code currently extends single line text items but could be simply adapted for multi-line text items or combo-boxes.
The filtering takes place in the Java client, before the data is sent to Forms services for validation.
The KeyFilter demo consists of the following files (relative directories shown in brackets):
The doc directory and the classes directory contain the JavaDoc for the code and the compiled classes respectively
In order for an application to be able to use the KeyFilter PJC the relevant configuration in the formsweb.cfg file has to ensure that the supplied keyfilter.jar (or another jar file containing the compiled keyfilter.class) is included in the relevant archive setting.
An entry in the formsweb.cfg file for an application that used the KeyFilter PJC would look like this:
[KeyFilter] pageTitle=OracleAS Forms Services - KeyFilter Demo IE=jinitiator baseHTMLJInitiator=demobasejini.html archive_jini=frmall_jinit.jar,keyfilter.jar form=keyfilterforms/java width=675 height=480 separateFrame=false splashScreen=no lookAndFeel=oracle colorScheme=blue background=/formsdemo/images/blue.gif
To use the KeyFilter PJC you must first create a normal Forms text item (single line) and set the Implementation Class property for this item to oracle.forms.demos.KeyFilter. Note that this property is case sensitive and must be entered exactly as shown.
By default the item continues to operate just like a normal text item, in order to enable the filtering capability you must set a custom property on the item FILTER_TYPE to one of the following the string values:
So to set a filter to only accept numbers:
SET_CUSTOM_PROPERTY('PJC.SALARY',1,'FILTER_TYPE','NUMERIC');
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.
If a FILTER_TYPE of CUSTOM is selected, you will have to set another custom property CUSTOM_FILTER to a string value which contains all of the characters that you wish to allow into the field.
For instance to define a field that can accept positive or negative Hexadecimal numbers:
SET_CUSTOM_PROPERTY('PJC.DUMP_OFFSET',1,'CUSTOM_FILTER','+-01234567890ABCDEF'); SET_CUSTOM_PROPERTY('PJC.DUMP_OFFSET',1,'FILTER_TYPE','CUSTOM');
As well as being able to get an set filters for the field, the PJC also gives the programmer access to information about the last keystroke that was made into the field. For instance to get the ASCII code of the last key pressed:
result := GET_CUSTOM_PROPERTY('PJC.FILTER_FIELD',1,'KEY_CODE');
See the Custom Property list below for the fill list of values that can be obtained.
Property | Get | Set | Valid Values / Return Value | Purpose |
---|---|---|---|---|
FILTER_TYPE | Yes | Yes | ALPHA | NUMERIC | ALPHANUMERIC | CUSTOM | NONE | Defines the filter to be used |
CUSTOM FILTER | Yes | Yes | String | To define a non-standard filter - any string containing the characters to allow |
KEY_CODE | Yes | No | String | ASCII code of the last key pressed |
KEY_CHARACTER | Yes | No | String | Character of the last key pressed - or Function key surrounded by braces e.g. {F1} |
KEY_MODIFIER | Yes | No | String ALT, CRL, SHIFT (or combination) | The modifier in force when the last key was pressed |
DEBUGMESSAGES | No | Yes | 'true' | 'false' | Enables/disables debugging to the Java Console for this instance of the control. |
DEBUGMESSAGES_ALL | No | Yes | 'true' | 'false' | Enables/disables debugging to the Java Console for all instances of the control. |