JSpell Integration Information

This Pluggable Java Component (PJC) provides a demonstration of providing spell check capability in a single or  multi-line text field within a form. This PJC does not perform spell checking itself but provides an interface with JSpell 2.0 from the Solution Cafe inc. (www.thesolutioncafe.com/jspell.html). You must have purchased the JSpell software separately in order for this PJC to function. The JSpell software is not included with this package.

These instructions assume that JSpell is already installed , configured and working.

Modules In This Demo

This distribution contains both the source code for the PJC as well as a demo and compiled versions. When unzipped you will see the following files (relative directories shown in brackets):

  1. jspell.fmb/fmx [forms] - The demo form
  2. JSpellIntegration90.pll [forms] - A library containing convenience methods for integrating Spell Checking
  3. SpellCheckTextArea.java / SpellCheckTextField.java [src/oracle/forms/demos/jspell] - source code for the PJC classes
  4. jspellintegration.jar [classes]- the compiled and jarred java class.

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 JSpell integration PJCs the relevant configuration in the formsweb.cfg file has to ensure that the supplied jspellintegration.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 JSpell Integration  would look like this:

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

Note: the jar file is supplied with the JSpell product and should be made available for Forms to download along with the jspellintegration.jar file.

Using the PJC in your Form

To use the JSpell PJCs you must first create a normal Forms text items that you want to spell check enable.

Then set the Implementation Class property for each item to one of the following:

Note that this property is case sensitive and must be entered exactly as shown.

You will also need to attach the supplied jspellintegration90.pll PL/SQL library to your form.  

Enabling and Using the JSpell Integration capabilities of the PJC

At Forms startup you need to define information about the JSpell Dictionary Server that is being used. All the settings such as this Server can be defined on an item by item basis or globally. If you have several JSpell enabled fields in your Form you will probably want to define the settings just once, rather than for each and every JSpell enabled field. To do this you must first register each of the JSpell enabled fields  using the JSpell.Register() procedure. For instance; JSpell.Register('EMP.RESUME'); You can then call the various functions to set the dictionary preferences, without specifying a field and all registered Items will have those settings applied. 

To define the dictionary you need to supply three bits of information.

  1. Firstly, if the Dictionary Server is operating in SOCKETs or SERVLET mode. The JSpell.SetDictionaryType() procedure is used for this.
  2. Secondly, the machine name or IP address of the Dictionary Server. The JSpell.SetDictionaryServer() procedure is used for this. If you don't define the Server, then the default is to use the same server name as the one that Forms Services is running on.
  3. Finally the Port being used by the Dictionary Server The JSpell.SetDictionaryPort() procedure is used for this. If you don't define a dictionary Port then the default JSpell ports are assumed - 80 for the Servlet and 5317 for Sockets.

The WHEN-NEW-FORM-INSTANCE would be the normal trigger for doing this initialization.

/*----------------------------------------------------*
* Sample When-New-Form-Instance trigger for setting up
* JSpell integration
*---------------------------------------------------*/
Begin
  -- Register any JSpell enabled fields
  JSpell.Register('EMP.RESUME');
  JSpell.Register('EMP.NOTES');

  -- Now set up the dictionary for all of those
  -- We're using the server in Sockets mode
  -- This information would not normally be hardcoded
  -- but passed in in some way...
  JSpell.SetDictionaryType(JSpell.SOCKET);
  JSpell.SetDictionaryServer('SPELLSERVER.MYCOMPANY.COM');
  JSpell.SetDictionaryPort(5317);
end;

Add any further Setting to configure the Spelling options such as how to handle uppercase words etc. (see the API section below). This could also be done in the When-New-Form-Instance trigger, or equally later on, maybe from a user configuration screen.

JSpell.SetIgnoreUppercase(TRUE);

Once the dictionary and connection options are configured you can spell check a field by calling the following code:

For a specific field:

begin
  JSpell.SpellCheck('<FieldName>');
end;

or, if you want a generic trigger that will check the current field:

begin
  JSpell.SpellCheck(:SYSTEM.CURSOR_ITEM);
end;

 

The JSpell Integration PL/SQL API

You can manipulate the JSpell integration PJC by calling SET_CUSTOM_PROPERTY directly on a spell check enabled field. However, to make the coding simpler the JSpell PL/SQL package provides a series of convenience program units.

Main Functions in the JSpell package

Function Purpose

Register (FieldName in VARCHAR2)

Register (FieldID in ITEM)

Registers an item so that global changes made though this API can be applied to it..

  • FieldName should contain the block and field name of the Item that is spellcheck enabled
  • FieldID An overloaded version of Register is supplied to take the Item by ID as well as name

SpellCheck (FieldName in VARCHAR2)

SpellCheck (FieldID in ITEM)

Actually performs the spell check on the named Item.

  • FieldName should contain the block and field name of the Item that is spellcheck enabled
  • FieldID An overloaded version of SpellCheck is supplied to take the Item by ID as well as name

SetDictionaryType(FieldName in VARCHAR2, DictionaryType in PLS_INTEGER)

SetDictionaryType(FieldID in ITEM, DictionaryType in PLS_INTEGER)

SetDictionaryType(DictionaryType in PLS_INTEGER)

Defines the type of Dictionary Server being used - Socket or Servlet. If the version of this procedure without a FieldName or FieldID is used then the setting will be applied to all registered fields, otherwise the setting will be applied to the specified field only.

  • FieldName [optional] should contain the block and field name of the Item that is spell check enabled
  • FieldID [optional] An overloaded version of the procedure is supplied to take the Item by ID as well as name
  • DictionaryType Takes a constant, either JSpell.SOCKET or JSpell.SERVLET

SetDictionaryServer(FieldName in VARCHAR2, DictionaryServer in VARCHAR2)

SetDictionaryServer(FieldID in ITEM, DictionaryServer in VARCHAR2)

setDictionaryServer(DictionaryServer in VARCHAR2)

Sets the Machine name or IP address of the JSpell Dictionary server: If the version of this procedure without a FieldName or FieldID is used then the setting will be applied to all registered fields, otherwise the setting will be applied to the specified field only.

  • FieldName [optional] should contain the block and field name of the Item that is spell check enabled
  • FieldID [optional] An overloaded version of the procedure is supplied to take the Item by ID as well as name
  • DictionaryServer Takes a string containing the name or IP address of the server.

SetDictionaryPort(FieldName in VARCHAR2, DictionaryPort in PLS_INTEGER)

SetDictionaryPort(FieldID in ITEM, DictionaryPort in PLS_INTEGER)

SetDictionaryPort(DictionaryPort in PLS_INTEGER)

Sets the Port used by the JSpell Dictionary server: If the version of this procedure without a FieldName or FieldID is used then the setting will be applied to all registered fields, otherwise the setting will be applied to the specified field only.

  • FieldName [optional] should contain the block and field name of the Item that is spell check enabled
  • FieldID [optional] An overloaded version of the procedure is supplied to take the Item by ID as well as name
  • DictionaryPort Takes an integer containing the port number of the server.

SetIgnoreUppercase(FieldName in VARCHAR2, Value in BOOLEAN)

SetIgnoreUppercase(FieldID in ITEM, Value in BOOLEAN)

SetIgnoreUppercase(Value in BOOLEAN)

Defines how the spell check should handle words in all uppercase: If the version of this procedure without a FieldName or FieldID is used then the setting will be applied to all registered fields, otherwise the setting will be applied to the specified field only.

  • FieldName [optional] should contain the block and field name of the Item that is spell check enabled
  • FieldID [optional] An overloaded version of the procedure is supplied to take the Item by ID as well as name
  • Value Boolean - If TRUE, uppercase words will not be checked.

SetIgnoreIrregularCaps(FieldName in VARCHAR2, Value in BOOLEAN)

SetIgnoreIrregularCaps(FieldID in ITEM, Value in BOOLEAN)

SetIgnoreIrregularCaps(Value in BOOLEAN)

Defines how the spell check should handle words with irregular capitalization: If the version of this procedure without a FieldName or FieldID is used then the setting will be applied to all registered fields, otherwise the setting will be applied to the specified field only.

  • FieldName [optional] should contain the block and field name of the Item that is spell check enabled
  • FieldID [optional] An overloaded version of the procedure is supplied to take the Item by ID as well as name
  • Value Boolean - If TRUE, words with irregular capitalization will not be flagged

SetIgnoreFirstCaps(FieldName in VARCHAR2, Value in BOOLEAN)

SetIgnoreFirstCaps(FieldID in ITEM, Value in BOOLEAN)

SetIgnoreFirstCaps(Value in BOOLEAN)

Defines how the spell check should handle words at the start of the field without an initial capital letter: If the version of this procedure without a FieldName or FieldID is used then the setting will be applied to all registered fields, otherwise the setting will be applied to the specified field only.

  • FieldName [optional] should contain the block and field name of the Item that is spell check enabled
  • FieldID [optional] An overloaded version of the procedure is supplied to take the Item by ID as well as name
  • Value Boolean - If TRUE, initial words without an initcap will not be flagged

Utility Functions in the JSpell package

The following function provides help when using JSpell.

Function Purpose
SetDebug (DebugOn in BOOLEAN)

Takes a boolean value to switch Debug mode on. When Debug mode is on, various informational messages will be written to the Java console as the upload process progresses.