RapidSpell Web Java Documentation: Terms & Conditions

Terms & Conditions

If you do not agree to these terms and conditions then you may not install, use, or distribute RapidSpell Web.

1. License and Ownership RapidSpell Web is a licensed software product. RapidSpell Web, including its accompanying files and documentation, is owned and copyrighted by Keyoti Inc., © Copyright 2003-2016, all rights reserved. Keyoti Inc. grants the user in possession of an official receipt of purchase a nonexclusive license to download and use the software, for any lawful commercial or non-commercial purposes provided the terms of this agreement are met.

2. Distribution. If you purchased a One Developer License Version then you may copy and use the RapidSpell Web distribution file (.zip) on any systems you use but for your development use only. If you purchased a multi developer license version then the number of developers specified in the license type are afforded the rights of a One Developer License. Development use is defined as one person having the ability to read or copy any of the files originally contained in the RapidSpell distribution file including (but not limited to) the .jar, .java, .html, .gif, .jpg, .bat, and .txt files. You must take appropriate safeguards to protect this product from unauthorized access by others.
If you purchased a Site License Version of RapidSpell Web, then you may provide copies of the RapidSpell Web distribution file (.zip) to anyone employed by your company whose primary work address is within a 100 mile (160 km) radius of your primary work address. If you purchased an Enterprise License Version then you have the same rights as the Site License with, however, no geographical or numerical restrictions on the locations to which you may provide copies of the RapidSpell Web distribution file. These individuals then have license rights and responsibilities equivalent to the Developer License Version.
In all cases the copies of the RapidSpell Web distribution file (.zip) must be unaltered and complete, including this license agreement and all copyright notices.
Evaluation version must not be re-distributed in any form.
You may not reverse engineer, disassemble, decompile, or modify this software or its accompanying documentation in any way.
You may reproduce and redistribute a copy of the jar files as part of any Java based software developed and licensed by you that itself uses RapidSpell Web provided
a) your software is installed on no more web-site domains or servers than specified by the license type purchased,
b) your software has clearly distinct and added functionality,
c) you are responsible for all technical support,
d) the RapidSpell Web application programming interfaces are not documented, exposed, or otherwise made available by your software,
e) attribution is given to Keyoti Inc. (http://www.keyoti.com) in any documentation or screen displays where other credits appear,
f) you do not allow recipients of your software to reverse engineer, disassemble, decompile, or copy portions from your software allowing them to gain separate access to RapidSpell Web or any parts of it.
The source code samples included with this package and in the RapidSpell Web documentation may be freely used, modified, incorporated, and distributed without restriction as part of any software that uses RapidSpell Web itself,
g) your software is not used by software or web developers as part of their application, and
h) your software is not a software component or JSP Tag.

3. Warranty Disclaimer and Limitation of Liability. RapidSpell Web is licensed to the user on an "AS IS" basis. Keyoti Inc. MAKES NO WARRANTIES, EITHER EXPRESSED OR IMPLIED, WITH RESPECT TO THIS SOFTWARE AND ITS ASSOCIATED FILES AND DOCUMENTATION, INCLUDING BUT NOT LIMITED TO ANY WARRANTY OF MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE. KEYOTI INC. DOES NOT WARRANT THAT THE OPERATION OF THIS SOFTWARE WILL BE UNINTERRUPTED OR ERROR FREE, OR THAT DEFECTS WILL BE CORRECTED. You the user are solely responsible for determining the appropriateness of this software for your use and accept full responsibility for all risks associated with its use. Keyoti Inc. is not and will not be liable for any direct, indirect, special or incidental damages in any amount including loss of profits or interruption of business however caused, even if Keyoti Inc. has been advised of the possibility of such damages. Keyoti Inc. retains the right to, in its sole discretion, refund the purchase price of this software as a complete and final resolution to any dispute.

SPECIFIC DISCLAIMER FOR HIGH-RISK ACTIVITIES. The SOFTWARE is not designed or intended for use in high-risk activities including, without restricting the generality of the foregoing, on-line control of aircraft, air traffic, aircraft navigation or aircraft communications; or in the design, construction, operation or maintenance of any nuclear facility. Keyoti Inc. and its suppliers specifically disclaim any express or implied warranty of fitness for such purposes or any other purposes.

NO LIABILITY FOR CONSEQUENTIAL DAMAGES. To the maximum extent permitted by applicable laws, in no event shall Keyoti Inc. or its suppliers be liable for any damages whatsoever (including without limitation, damages for loss of business profits, business interruption, loss of information, or other pecuniary loss) arising out of the use of or inability to use this Keyoti Inc. product, even if Keyoti Inc. has been advised of the possibility of such damages. Because some states and jurisdictions do not allow the exclusion or limitation of liability for consequential or incidental damages, the above limitation may not apply to you.

4. Support and Source Code Licensing. Keyoti Inc. does provide formal customer support contracts for RapidSpell Web. We also make every effort to ensure the quality of our products, and questions, bug reports, and feature requests are encouraged, please use email. Due to resource limitations, it may not be possible to resolve all issues and no assurances can be given as to when or if problems will be addressed. Customers incorporating RapidSpell Web into software for deployment or sale are encouraged to purchase the Source Code License Version of RapidSpell Web which will enable self-support, debugging, and modifications or extensions to the base functionality (but not distribution of the source code itself).


RapidSpell Web Java Documentation: Introduction

Introduction

Thank you for purchasing RapidSpell Web, please keep up to date through our website keyoti.com

and feel invited to post feedback. We also ask that you register your purchase so that we may offer you

support and free upgrades from time to time, at http://keyoti.com/care/register

Online Resources

We invite you to visit our Knowledge Base and Support forum at https://keyoti.com/kb and

http://keyoti.com/support.

Overview

RapidSpell Web provides a spelling component to add spell checker functionality to your web applications by simply adding either two .js files to any web page or by adding a JSP Tag to a JSP page or using the Beans in Servlets. There are no programming skills required to use RapidSpell Web Tags, making it accessible to JSP page designers as well as Java programmers. The UI provides all the usual features, add, change, change all, ignore, ignore all, undo, and smart suggestions. It interactively checks any HTML text box component such as <textarea> and <input type=’text’> aswell as 3rd party rich Html text box components. The spell checker UI features an advanced preview pane to interactively highlight errors (with no post back). The spell checker accepts manual corrections, and also supports user dictionaries (either one dictionary for all users or separate user dictionaries). The included non GUI component provides core spell checker functionality at the middleware level, which means it is suitable for server applications as well as any console application.

Common Uses

The Tag components can check any Html text component (e.g., <textarea>, <input type=’text’> and 3rd Party). The non-GUI component provides core spell checking functionality, allowing it to be useful in any application, including: Server applications and Console based applications.

Requirements

The components were built to JSP1.2 specifications, they were developed and tested on Tomcat 4+,IBM WebSphere, JBoss and Bea WebLogic.


RapidSpell Web Java Documentation: Release Notes

Release Notes

To prevent exceptions being reported about problems loading the Dict File (which could be a security risk as it could provide information about the existence of system files), please disable warnings when deploying to production. 1. Set a parameter called RapidSpellHideDictFileExceptions in web.xml to "true". eg.
<?xml version="1.0" encoding="UTF-8"?>

<web-app ...>

    <context-param>
        <param-name>RapidSpellHideDictFileExceptions</param-name>
        <param-value>true</param-value>
    </context-param>

....
</web-app>
It may be necessary to restart the app. server after changing the web.xml, for it to have effect.

5.3.0

Breaking Changes:

UserDictionary.readAll has changed to accept ArrayList as a parameter, if you have a subclass of UserDictionary (eg for a database based user dictionary), please change your subclass to use ArrayList in the readAll method arguments

Improvements
-Added Servlet API 5 compatible JAR.
-Cookies used by RapidSpell to hold user option selections now have the Secure attribute set when run on HTTPS.
-Fixed problem when Undo button is not visible.
-English dictionary update.
-Added ability to set field labels for the dialog checker with JS mode usage, see Dialog page in the help.
-Fixed issue with IE11 running in IE9 mode causing browser crash.
-Added event hook ups for keypress and input.
-Support change events in AngularJS.
-Fix bug in dialog check where words could be incorrectly ignored

5.2.0

Breaking Changes:

See 5.0.0 release notes below if you are upgrading from v4 or older. Otherwise no breaking changes

Improvements
-Added ability to set field labels for the dialog checker with JS mode usage, see Dialog page in the help.
-IE7 Fix browser contextmenu being shown when right clicking on error word.
-Chrome v57 introduced an issue with INPUT (single line) text boxes being wrongly sized in height, which has been fixed.
-Fixed issue with cursor not being visible (when first clicked) in single line text boxes in Chrome.
-Russian translation correction.

5.1.0

Breaking Changes:

See 5.0.0 release notes below if you are upgrading from v4 or older. Otherwise no breaking changes

Improvements
-Added Polish and Russian UI texts
-Added support for jQuery Combobox
-Added support for jQuery autosize - please email support@keyoti.com for info
-Added documentation on using with KendoUI rich text box, see 3rd party text box section of the help
-Improved handling of textboxes made invisible and then visible again
-Added rsw_unregisterTextBox(textBoxId) function to remove textbox from spell checker
-Added preventDefaultCurrentEvent function to allow event cancellation (eg key events), see the Client Scripting section of the help
-Added double click event mapping to original textbox with as you type mode
-Addressed nodeValue being deprecated
-Fixed Firefox issue with newlines
-Fixed bug with textboxes marked to be ignored being picked up under certain conditions
-Prevent suggestions context menu being hidden as textboxes are initialized
-Fix bug in text reconciliation (for text changes occurring after a spell request was sent)
-Map double click events to source textbox handler (for AYT)
-Added submitOnEnterForSingleLine property to TBS objects to allow Enter to trigger form submit - please email support@keyoti.com for info
-Fix placeholder bug
-Added rapidSpell.ayt_forceNoScrollBars to allow complete override of scroll bars in AYT textboxes (false by default), useful with older browsers in certain document modes

5.0.0

Breaking Changes:

There are 3 breaking change sections below, please check them for their applicability to your project (if you need help just email support@keyoti.com). The changes relate to user options, popup window javascript function/variable naming and a new CSS block that must be added to your popup.jsp (if applicable).

User options

A new feature is user options in the dialog spell checker, which give the user the ability to enable/disable spell check options such as ignore words with numbers, ignore uppercase, ignore improper case and ignore internet addresses. These options are stored in the user's cookie and will override any same setting made in code (such as with rapidSpell.setParameterValue(...)).

To disable this functionality call (for Javascript based usage):

rapidSpell.setParameterValue('default', 'EnableOptions', 'false');

or (for JSP Tag based usage), set enableOptions to false in the RapidSpellWebLauncher tags.

Popup window variable and function names (small possibility you are affected)

To implement the new jQuery based dialog it was necessary to incorporate the popup window scripts on the main page. This necessitated renaming of some Javascript variables and functions, and HTML elements. Therefore if your code is reliant on the elements in the page holding RapidSpellWeb tag (the popup) being named a certain way (eg. you have Javascript that references HTML elements from our RapidSpellWeb tag, or you have Javascript that calls our functions) then you will need to update references to the new names (in most cases the names have been prepended with "rsw_". If you are unsure, please send your JSP page that holds the RapidSpellWeb tag to support@keyoti.com and we will advise.

Example, you have a customized popup UI, with this code:

<FinishButton BorderWidth="" Font-Size="9pt" Font-Names="Verdana" Font-Bold="True" BorderColor=""
                        ForeColor="" BackColor="SkyBlue" Height="" Width="100px" CssClass="" type="button" value="Finish"
                        onclick="finish(true);" style="width:100px;font-family:Verdana;font-size:9pt;font-weight:bold;background-color:#87ceeb;"
                        ID="cancelButton"></FinishButton>

The ID of the cancel button has changed and should be updated to:

ID="rsw_cancelButton"

Other changes are:

changeSuggestions() => rsw_changeSuggestions()
ignoreCurrent() => rsw_ignoreCurrent()
ignoreAll() => rsw_ignoreAllInstances
change() => rsw_change()
changeAll() => rsw_changeAll()
addCurrent() => rsw_addCurrent()
undoChange() => rsw_undoChange()

Other function and variable names have changed, but it is expected that they have not been used publically. It is recommended that you retest any popup scripts that have been added, or send to us for our guidance.

Popup window requires new CSS block

To support the user options, a CSS style block must be added to the popup.aspx page (note that your popup page may be named a different name, it will be the ASPX page holding the <RapidSpellWeb> Server Control). Please add the following to the head tags.

<style type="text/css">

        body{overflow:hidden;
             font-family: sans-serif, arial, helvetica;

        }
        div{height:100%;}

        #rsw_documentTextPanel
        {
            border: 1px solid #aaa;
            border-radius: 3px;
        }
        #rsw_word, #suggestions
        {
            border: 1px solid #aaa;
            border-top-color: #a0a0a0;
        }
        #rsw_optionsDialog
        {
            font-size:.80em;
            display: none;
            position: absolute;
            margin-left: auto;
            margin-right: auto;
            margin-top: auto;
            margin-bottom: auto;
            left: 0;
            right: 0;
            top: 0;
            bottom: 0;
            width: 295px;
            height: 230px;
            z-index: 101;
            background-color: white;
            border: 1px solid #444;
            border-radius: 5px;
            padding: 8px;
        }
        #rsw_optionsDialog_Backing
        {
            display: none;
            position: absolute;
            margin-left: auto;
            margin-right: auto;
            margin-top: auto;
            margin-bottom: auto;
            left: 0;
            right: 0;
            top: 0;
            bottom: 0;
            width: 100%;
            height: 100%;
            background-color: rgba(100,100,100,.60);
            z-index: 100;
        }
        #rsw_optionsDialog > label
        {
            display: block;
            padding-bottom: 12px;

        }
        #rsw_optionsDialog > input
        {
            margin-right: 9px;
            margin-top:12px;
        }
        #rsw_optionsHeader
        {
            font-size: 1.2em;
            border-bottom: 1px solid #aaa;
        }
    </style>
Improvements
-Spell check options dialog added.
-Added support for the context menu key on the keyboard, and enabled selection of suggestion menu items with keyboard.
-Edge browser support added.
-jQuery UI based dialog mode added (for Javascript based usage only).
-Modal mode improvement to use jQuery UI dialog (must enable with rapidSpell.dialog_setUseDivDialog(true);) (for Javascript based usage only)
-Smaller bug fixes
4.2.0 ----- -Spell checker can now look for elements to check by their class rsw_spellable. This allows textboxes to be checked by inclusively specifying them rather than excluding them. -Address some XSS issues with dialog spell checker. -Fix IE11 not tabbing to other textboxes. -Fix issue parsing some HTML content with entities. -Fix textbox overlay sizing issue with RapidSpellWInline tag usage and IE7, in static mode. Backwards Compatibility -Compatible with 4.1.0 4.1.0 ----- -Make dictionary cache reload modified versions of a dictionary. -Added ability to ignore URLs and emails. -Added support for cross subdomain usage. -Fix bug with dialog spell checker freezing. -Fix Chrome/FF cursor positioning bug. Backwards Compatibility -The new text parser is more accurate around symbols, and allows the control to ignore emails and URLs. To deactivate URL/Email ignoring set IgnoreURLsAndEmailAddresses=false, to revert to the old parser set V2Parser=false (note V2 refers to the version of the parser, not the version of the controls). If you have customized the spell checker to handle symbols differently, it is recommended that you check functionality is the same with the V2Parser enabled. -The 'static mode' overlay has changed from being absolutely positioned to temporarily setting the target textbox to display:none and inserting the overlay in the DOM before the target textbox - we recommend checking that this does not have detrimental effects on layout in your apps. Set rsw_absolutePositionStaticOverlay = true; in Javascript on the page to revert to old behavior. 4.0.0 ----- Up until v4 everything was JSP Tag based, nothing was Javascript client based. During this period of time other technologies have been released, such as JSF, JQuery, etc - the trend has been for developers to be more Javascript aware. With multiple 'form factors' in use, it makes sense for RapidSpell Web v4 to become Javascript based, which has advantages; -Usable with technologies that don't support JSP tags -Simpler usage, 99% automatic -Smaller footprint on your application -Simpler product development (less mirroring of properties) We are including the Tags for developers who are not comfortable with Javascript and for backwards compatibility. As you develop new pages we urge you to try using the Javascript based methodology as we're sure you'll find it better. Backwards Compatibility -Is backwards compatible, no code changes required. To transition away from the control based usage please remove the controls and follow the Help instructions on JS based usage. -"ShareDictionary" code from prior versions is ignored as it has been superseded by automatic caching. Improvements -As you type support added for Chrome and Safari browsers -Inclusion of simpler, more flexible automatic setup scripts, which will spell check all textboxes unless otherwise indicated (see docs). -Automatic dictionary caching, supports multiple dictionaries per app. -Filter suggestions that would make text longer than 'maxlength' -Inline ignore all removes underlines in all text boxes and not just current 3.2.0 ----- -Support Internet Explorer 9 -Support Firefox 4 -Fix occasional cursor jumping in IE -Fix issue with ALT code characters disappearing in RapidSpellWInlineTextBox with as-you-type if they were the last character entered. Backwards Compatibility ----------------------- ************************************************************************* BREAKING CHANGE Due to a security concern relating to the user dictionary file mechanism, we have implemented a global parameter to prevent malicious injection attacks. If you are in a secure environment (eg. a protected intranet app) then you can revert to legacy behavior by either setting RapidSpellUserDictionaryLegacyMode to true in web.xml, eg. RapidSpellUserDictionaryLegacyMode true .... OR - by setting legacyUserDictionaryMode="true" in the RapidSpellWeb tag (this tag is in the popup). OTHERWISE - As of 3.2 please set a paramter called RapidSpellUserDictionaryDirs in web.xml to a comma delimited list of directories where you intend to store user dictionary files. eg. RapidSpellUserDictionaryDirs C:\my-app\user-dicts\ .... this will mean that userDictionaryFile in the tags must be set to a file under C:\my-app\user-dicts\. ALSO, user dictionaries must now be .txt files, so with the above setting a valid userDictionaryFile value is "c:\my-app\user-dicts\somename.txt" ************************************************************************* Version 2 license keys are NOT usable with v3, please purchase an upgrade. Version 3 is fully backwards compatible with v2.0. The "callBack" property/attribute in RapidSpellWebLauncher class/tag has been deprecated for "popup" mode - please remove calls to it. It is still in use for "separate" mode. The RapidSpellWeb.tld file no longer needs to be placed in the WEB-INF folder, please register the taglib in your JSPs with; <%@ taglib uri="http://www.keyoti.com/" prefix="RapidSpellWeb" %> History ------- 3.1.0 ----- -Global change all added to the dialog spell checker - set globalChangeAll="false" in RapidSpellWeb tag to deactivate. -Fix 'focus flash' in FF3 with multiple text boxes at end of spell check. 3.0.1 ----- -Fix for FF3 issue with multiple text boxes in dialog mode 3.0.0 ----- -Inline and as-you-type spell checking added -Improved support for Struts and JSF -Ignore all action now global to all text boxes -Multiple RapidSpellWebMultiple tags can now be used -It is now assumed that the character encoding used in application servers will be UTF-8 (instead of the previous value of "8859_1"), if this is not correct then non ASCII chars (i.e. accents) may appear as boxes or question marks. The RapidSpellWeb tag (popup) has an attribute assumedApplicationEncoding which can be set to whatever encoding the application server is using. -Dictionary update. Backwards Compatibility ----------------------- Version 2 license keys are NOT usable with v3, please purchase an upgrade. Version 3 is fully backwards compatible with v2.0. The "callBack" property/attribute in RapidSpellWebLauncher class/tag has been deprecated for "popup" mode - please remove calls to it. It is still in use for "separate" mode. The RapidSpellWeb.tld file no longer needs to be placed in the WEB-INF folder, please register the taglib in your JSPs with; <%@ taglib uri="http://www.keyoti.com/" prefix="RapidSpellWeb" %> 2.4.0 Notes & Backward Compatibility ------------------------------------ The "callBack" property/attribute in RapidSpellWebLauncher class/tag has been deprecated for "popup" mode - please remove calls to it. It is still in use for "separate" mode. "Smooth transitions" & "Undo" functionality have been added to this version (see below) and are enabled by default, since this changes behaviour from previous versions, you may wish to disable them, but setting RapidSpellWebLauncher.enableUndo = false, and RapidSpellWebMultiple.useSmoothTransitions = false. 2.4.1 Improvements ------------------ -LeaveWindowOpenForUndo property added to RapidSpellWebLauncher to set whether the popup stays open after the last error is dealt with, giving the user a chance to undo their change before committing. 2.4.1 Fixes ----------- -Fixed performance related issue with certain JDK versions. 2.4.0 Improvements ------------------ -Smooth transitions (between text boxes) for RapidSpellWebMultiple has been added (useSmoothTransitions property) -Undo functionality has been added (enableUndo property in RapidSpellWebLauncher) -Improved suggestions for short (2, 3 letter) words -LookIntoHyphenatedText property added to RapidSpellWebLauncher -CheckCompoundWords Property added to RapidSpellWebLauncher 2.4.0 Fixes ----------- -Required UI properties added. -Updated .tld file. 2.3.0 Improvements ------------------ -New RapidSpellWebMultiple Tag makes multiple check boxing cleaner and simpler. -Duplicate word detection added. -Script filtering added to prevent malicious Javascripts in text from running. -setDictFileStream in RapidSpellWeb tag and RapidSpellChecker facilitates Dict file loading from alternative sources (such as WAR files). -Safari and Opera browser support. -SSL friendly, SSL sites are now supported without the mixed content warning (set SSLFriendly attribute to true in Tags). -Modal popups supported with modal attribute in RapidSpellWebLauncher -Popup window position now settable. -buttonImageMouseOut/Over/Down attributes allow images to be used instead of buttons, easily. -New properties added to define element styles in spell checker. -Portuguese UI texts and parser added to support new dictionary. -allowMixedCase attribute added to optionally allow errors such as "aFrIca" (default: false). 2.3.0 Fixes ----------- -No bugs to fix. 2.2.0 Improvements ------------------ -Improved suggestions algorithm for shorter words (5 letters or less) 2.2.0 Fixes ----------- -User dictionary and accented characters, malfunctions. 2.1.0 Improvements ------------------ -Servlet compatibility has been added, allowing RapidSpell Web Java to be used with full functionality in Servlets. -Smoother multiple text box checking, multiple text boxes can be checked with one button (consult demo). -Dict file functionality added for run-time switchable dictionaries. -International UI text added for French, German, Spanish and Italian. 2.0.2 Fixes ----------- -If the user pressed enter in the change text field a 404 error occurred, behaviour has been corrected to change the word to new text. -Accented characters not being picked up correctly when HttpServletRequest encoding not set to UTF8, fixed. 2.0.1 Fixes ----------- -An issue with WebLogic Server and the custom layout of the spell checker using the Layout property. WebLogic fails to accept properties with newline characters in them. This property may be entered without new lines in them. 2.0.0 Fixes ----------- -An error in the TLD prevented operation with WebLogic Server, this has been corrected.


RapidSpell Web Java Documentation: The Dictionaries

The Dictionaries

Included are 4 dictionary assemblies, UK and US English dictionaries, each containing ~150K words, a combined UK and US dictionary containing ~155K words. These can be found in the ‘dictionaries’ directory.

User (Custom) Dictionary Files

To enable the 'Add' option, please see the user dictionary examples;
  • For Javascript based usage: inline and dialog.
  • For JSP Tag based usage: inline and dialog spell checkers.


RapidSpell Web Java Documentation: Installation & Deployment

Installation & Deployment

1. To use RapidSpell Web, you must add either the RapidSpellWeb.jar (if your app server uses Servlet API 1 to 4, eg Tomcat 9 or older) or the RapidSpellWeb-Jakarta.jar (if your app server uses Servlet API 5+, eg Tomcat 10 or newer) and RapidSpellMDict.jar files to the lib directory of your web application.

2. Register a Servlet in your web.xml file. To do this;

i) Open web.xml under /web-inf (for an example of a complete web.xml file with this, please see the RapidSpellDemo application included with this product)

ii) Add this block (if other <servlet> sections exist, add it directly below them), inside the <web-app> elements.

<servlet>

<description>Handles requests for RapidSpell Web</description>

<servlet-name>RapidSpellWebHandlerServlet</servlet-name>

<servlet-class>com.keyoti.rapidSpell.web.ControlServlet</servlet-class>

<init-param>

<param-name>licenseKey</param-name>

<param-value></param-value>

</init-param>

</servlet>

iii) Add this block below it (if other <servlet-mapping> sections exist, add it directly below them)

<servlet-mapping>

<servlet-name>RapidSpellWebHandlerServlet</servlet-name>

<url-pattern>*.rapidspellweb</url-pattern>

</servlet-mapping>

iv) Add this block below it (if other <context-param> sections exist, add it below them) - this setting is explained in the user dictionary section.

<context-param>
        <param-name>RapidSpellUserDictionaryDirs</param-name>
        <param-value>~/</param-value>
</context-param>
Please note that in some server contexts (such as WAR files that are not 'exploded' on deployment) we may not be able to automatically resolve '~/' to the application root, in this case please set the param RapidSpellBaseDir.
<context-param>
        <param-name>RapidSpellBaseDir</param-name>
        <param-value>c:\path\to\app root\</param-value>
</context-param>

v) For an example of a complete web.xml file with this, please see the demo application included with the product.

3. There are two ways to use RapidSpell Web; from Javascript or from JSP tags.

  • Javascript based usage:
    • Import the RapidSpell-AYT.js and RapidSpell-DIALOG.js files on to the page using script tags:
      <script src="a.rapidspellweb?t=r&amp;n=RapidSpell-AYT.js"></script>
      <script src="a.rapidspellweb?t=r&amp;n=RapidSpell-DIALOG.js"></script>
      a.rapidspellweb is the servlet registered in your web.xml (see top of this page).
    • [Optional - use scripts directly, no servlet]

      Create a Keyoti scripts folder within the web application, copy the files from the 'ClientFiles' folder and paste them to a folder called 'Keyoti_RapidSpell_Web_Common'.
      (the 'ClientFiles' folder can be found in the distribution ZIP.)

      Import the scripts like this (instead of using the servlet URLs):

      <script src="/Keyoti_RapidSpell_Web_Common/RapidSpell-AYT.js"></script>
<script src="/Keyoti_RapidSpell_Web_Common/RapidSpell-DIALOG.js"></script>

Create a page called rswihelper.jsp (put it in Keyoti_RapidSpell_Web_Common folder) with this content

<%@ taglib uri="http://www.keyoti.com/" prefix="RapidSpellWeb" %>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">

<html>
    <head>
    </head>
    <body>

        <RapidSpellWeb:rapidSpellWInlineHelper
            licenseKey="....put your license key here...."
                                               />
    </body>
</html>

      and another page called popup.jsp with this content

      <%@ taglib uri="http://www.keyoti.com/" prefix="RapidSpellWeb" %>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
        <title>Spell Checking</title>

    </head>
    <body>

<RapidSpellWeb:rapidSpellWeb assumedApplicationEncoding="UTF-8"
licenseKey="...your license key here..."
/>

    </body>
</html>

      On the main page where scripts are imported add

      <script type='text/javascript'>
rapidSpell.ayt_helperURL ="/Keyoti_RapidSpell_Web_Common/rswihelper.jsp";
rapidSpell.dialog_popupURL ="/Keyoti_RapidSpell_Web_Common/popup,jsp";
</script>

  • JSP Tag based usage:
    Add the taglib directive to the top of each page using the tags.

    <%@ taglib uri="http://www.keyoti.com/" prefix="RapidSpellWeb" %>

Licensing The Components

RapidSpell Web requires a license key to be set in the application, if a key is not set, the

component will only run when the application is accessed through “localhost”. Furthermore, if the

RapidSpellChecker class is used separately, it too must have a license key set (in it’s constructor).

Evaluation Keys

Time limited evaluation keys can be generated automatically at

http://keyoti.com/products/evaluation-key-generator

Purchased Keys

If you have purchased licenses, please see the accompanying file “license-keys.txt” which explains in

detail how to generate “deployment keys”.

Setting A License Key

  • If using the product through Javascript

    Open web.xml under /web-inf, and look for the RapidSpellWebHandlerServlet servlet (see top of this page), place the license key inside the <param-value> tags, for the

    licenseKey property. Eg.

    <init-param>

    <param-name>licenseKey</param-name>

    <param-value>12345</param-value>

    </init-param>

    (the web application server, or ‘container’ must be restarted after this change).

    For multiple keys add extra licenseKey params, named; licenseKey2, licenseKey3 ... up to licenseKey6

  • If using the product through JSP Tags

    The license key (deployment key) is set as follows, depending on which component is being used.

    RapidSpellWeb (Dialog Spell Checker)

    The key can be set in the licenseKey attribute in the RapidSpellWeb Tag (which is in the popup page),

    eg;

    <RapidSpellWeb:rapidSpellWeb licenseKey="......."/>

    If setting multiple license keys, comma delimit them (with no spaces), eg "key1,key2,key3"

    RapidSpellChecker (Programmatic Spell Checker)

    The key can be set in RapidSpellChecker’s constructor, eg;

    RapidSpellChecker rapidSpellChecker = new RapidSpellChecker("........");

    RapidSpellWInline (Inline Spell Checker)

    This component can be used/licensed in 2 ways and the key is set accordingly:

    1. The standard/default way (when the rapidSpellWInlineHelperPage attribute in each

    RapidSpellWInline tag is not set in the JSP page) -

    Open web.xml under /web-inf, and look for the RapidSpellWebHandlerServlet servlet (see top of this page), place the license key inside the <param-value> tags, for the

    licenseKey property. Eg.

    <init-param>

    <param-name>licenseKey</param-name>

    <param-value>12345</param-value>

    </init-param>

    (the web application server, or ‘container’ must be restarted after this change).

    2. If rapidSpellWInlineHelperPage is set in the RapidSpellWInline tag -

    It is necessary to set the licenseKey attribute of the RapidSpellWInlineHelper tag (which is in the page

    specified by the rapidSpellWInlineHelperPage property).

    eg;

    <RapidSpellWeb:rapidSpellWInlineHelper licenseKey="......."/>

Security And Other Configuration Settings

User Dictionary Files

Please see the user dictionary examples, for the inline and popup spell checkers, for important information on configuration.

Dict File Warnings

To prevent exceptions being reported about problems loading the Dict File (which could be a security risk as it could provide information about the existence of system files), please disable warnings when deploying to production.

1. Set a paramter called RapidSpellHideDictFileExceptions in web.xml to "true".

eg.

<?xml version="1.0" encoding="UTF-8"?>

<web-app ...>

    <context-param>
        <param-name>RapidSpellHideDictFileExceptions</param-name>
        <param-value>true</param-value>
    </context-param>

....
</web-app>

It may be necessary to restart the app. server after changing the web.xml, for it to have effect.


RapidSpell Web Java Documentation: RapidSpellWeb (Dialog Spell Checker)

RapidSpellWeb (Dialog Spell Checker)

Standard Layout
Custom Layout

The RapidSpell Web dialog based checker consists of code to launch a popup page with the RapidSpellWeb control in it.

The user is shown the spell checker page, which will iterate through all the misspelt words in the text, highlighting them in the 'preview pane' and allowing the user to ignore, change, add etc. When the text has been checked the user will be prompted that the spell check has finished, and upon clicking OK.


RapidSpell Web Java Documentation: RapidSpellChecker (Programmatic Spell Checker)

RapidSpellChecker (Programmatic Spell Checker)

Provides a model (business/logic) level spell checker API which can be used in a client-server environment

and any applications where a client GUI does not exist. RapidSpellChecker has been

benchmarked at checking 50,000 words/second on a standard 1GHz PC. User dictionaries can optionally

be used, allowing words to be added. This component can be used in 2 different ways, in an iterative

fashion or on a query by query basis. Please see the API docs for code level details.

Using RapidSpellChecker in an iterative manner provides complete textual correction of strings similar

to a GUI based spell checker. A string is loaded into RapidSpellChecker and then successive calls to the

nextBadWord() method move through the string allowing findSuggestions() and

changeBadWord(replacement) to be called to find spelling suggestions and optionally correct the misspelt

words in the text, finally getAmendedText() returns the corrected text.

Alternatively RapidSpellChecker may be used in a simple query by query basis, calls to lookUp(word)

and findSuggestions(word) methods allow bare bones spell checking functionality.

Key API Points

Methods
RapidSpellChecker() | -argumentless constructor
check(text [, startPosition]) | -begins checking text
findSuggestions(word) | -finds suggestions for word
lookUp(word) | -checks if word is in either main or user dictionaries
setUserDictionary(file) | -allows you to define which file will be used as a user dictionary
ignoreAll(word) | -ignores all future occurrences of word
addWord(word) | -adds word to the user dictionary if it exists
nextBadWord() | -finds the next misspelt word in the text
changeBadWord(newWord) | -changes the misspelt word last identified by NextBadWord()
getAmendedText() | -returns the corrected text

Query by Query Usage Sequence Diagram

Iterative Usage Sequence Diagram

See examples section for examples.


RapidSpell Web Java Documentation: RapidSpellWInline (Inline/As-You-Type Spell Checker)

RapidSpellWInline (Inline/As-You-Type Spell Checker)

This style of spell checking is close to Windows 'as-you-type' spell checking. When the inline spell checker is setup (either through Javascript or through JSP Tags), the text box will be spell checked either as the user types, or on the click of a button. Underlines will appear and the user has the option to right click on the errors and select a suggestion, Add (to their user dictionary) or Ignore All.

The spell check requests are made through AJAX calls and the server processes them via a servlet.


RapidSpell Web Java Documentation: Dict Files

Dict Files

RapidSpell supports 2 types of dictionary, JAR (default) and .dict file. JAR based dictionaries are compressed, static and easier to deploy, whereas the .dict file format is faster and can be customized, however its path must be specified in code:

Using a JAR dictionary

This should be automatic, all that is required is that the RapidSpellMDict.jar is in the same folder as RapidSpellWeb.jar.

Customizing and using a .dict dictionary

  1. Find the ".dict" file version of the English dictionary you want to use (US) in the Dictionaries folder (inside the ZIP).
  2. Edit that .dict file using the DictManager tool (it's a GUI tool under the DictManager folder (inside the ZIP). You can add ones one at a time or from a text file.
  3. Use the .dict file by either calling
    • (For JS based usage) rapidSpell.setParameterValue('default', 'DictFile', '~/somedir/filename.dict');
      (where ~/ will be interpreted as the web application root)
    • (For Tag based usage, set in the RapidSpellWInline or RapidSpellWebLauncher tags) dictFile="~/somedir/filename.dict"
      (where ~/ will be interpreted as the web application root)
Programmatic use of Dict Manager
To use Dict Manager programmatically:
  • Add DictManager.jar to your classpath, or lib.
  • Create an instance: model = new com.keyoti.rapidSpell.DictManagerModel();
  • Use any of the API calls:
    • createDict
    • loadDict
    • addWord
    • mergeDictFile
    • mergeTextFile
    • removeWord
    • lookUp
    • saveDict
    • Creates a new dict file
    • Loads an existing dict file
    • Adds a word to current open dict file
    • Merges an existing dict file with the open dict file
    • Merges an existing text file with the open dict file
    • Removes a word from the dict file
    • Checks if a word is in the dict file
    • Saves the currently open dict file
  • Typical usages should be in the following order;
    • create or load
    • modifying operations
    • save.


About The Two Modes Of Usage

About The Two Modes Of Usage (Javascript & JSP Tag)

Up until v4 everything in RapidSpell Web was JSP Tag based and nothing was Javascript client based. During this period of time other technologies have been released, such as JSF, JQuery, etc - the trend has been for developers to be more Javascript aware. With multiple 'form factors' in use, it makes sense for RapidSpell Web v4 to become Javascript based, which has advantages;

  • Usable with technologies that don't support JSP tags (JSF, straight HTML etc)
  • Simpler usage, 99% automatic
  • Smaller footprint on your application
  • Simpler product development (less mirroring of properties)
The disadvantages are that it breaks compatibility, and that it may not be appealing to non Javascript developers. For that reason we are including the Tags. As you develop new pages we urge you to try using the Javascript based methodology as we're sure you'll find it better.

The examples section includes examples using both JS and tag based modes of usage.

The Javascript method and JSP Tags are incompatible and must not both be used on the same page.


RapidSpell Web Java Documentation: As You Type Spell Checking

As You Type Spell Checking

To enable as you type spell checking on a page with text-fields or text-areas (in HTML these are INPUT and TEXTAREA tags)

  1. Ensure the RapidSpell servlet is registered in the web.xml (per 'Installation').
  2. Import RapidSpell-AYT.js to the page, using <script src="a.rapidspellweb?t=r&amp;n=RapidSpell-AYT.js"></script>
    a.rapidspellweb is the servlet registered in your web.xml - the scripts can also be used directly, see 'Installation'
  3. All textboxes (with their id attribute set) will now be as-you-type enabled.
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <script src="a.rapidspellweb?t=r&amp;n=RapidSpell-AYT.js"></script>
    <title></title>
</head>
<body>
    <form>
        <textarea id="text1" cols="20" rows="10">Helloo this is as testt</textarea>
        <textarea id="text2" cols="20" rows="10">and some more</textarea>
    </form>
</body>
</html>
Tip: If the window.onload is being set on the user page, this can block the as-you-type spell checker from initializing properly. It is suggested that either of the following is used;

1. Store the current onload handler and call it explicitly. Eg. if the current code is window.onload=myHandler; then change it to

<script type="text/javascript">
    var existingOnloadHandler = window.onload;
    window.onload=myHandler;
    function myHandler(){
        if(typeof(existingOnloadHandler)=='function') existingOnloadHandler();
        //...current code
    }
</script>

2. Or, assign the onload handler using window.addEventListener (IE9 and others) or window.attachEvent (IE8 down).

If you receive Access Denied errors, add this code to your page (beneath the original src import):
<script type='text/javascript'>
rapidSpell.ayt_helperURL ="<%=request.getContextPath()%>/a.rapidspellweb?t=a";
</script>
If that doesn't help, it may be a cross domain issue, please email support@keyoti.com

Enabling/Disabling spell check on specific text boxes

To disable for specific text boxes
  • Add the attribute nospell="true" to the text box.
  • Or, add the (client) ID of text box to the Javascript array rapidSpell.ayt_ignoreTextBoxIds,
    eg. either 1 of
    rapidSpell.ayt_ignoreTextBoxIds[rapidSpell.ayt_ignoreTextBoxIds.length] = 'textBox1'; //where textBox1 is the id attribute of a textbox
rapidSpell.ayt_ignoreTextBoxIds[rapidSpell.ayt_ignoreTextBoxIds.length] = '<%= textBox1.ClientID %>'; //where textBox1 is an asp:textbox tag.
To enable for specific text boxes
  • Set rapidSpell.ayt_findByClass=true;
  • Add the CSS class 'rsw_spellable' to textboxes that should be spell checked.
    Eg. <input type='text' class='rsw_spellable' .../>
    Eg. when there are other classes specified already <input type='text' class='myTextBox rsw_spellable' .../>

    • If no elements are marked with the class rsw_spellable, then nothing will be spell checked. If elements are marked with rsw_spellable but also set to be ignored in the above array, they will not be spell checked.

Modifying or removing the 'Add' option

Please see the user dictionary topic.

Using a button to trigger spell check, instead of as the user types

In the HEAD of the page, add a Javascript block which calls rapidSpell.ayt_aytEnabled = false;

<script type="text/javascript">
    rapidSpell.ayt_aytEnabled = false;
</script>

Trigger the spell check using Javascript, eg. in a button click handler;

<input type="button" onclick="rapidSpell.ayt_spellCheck(document.getElementById('textBox1'))" value="Spell Check" />

Static mode

In this mode, the spell check is triggered by a button, and the underlines are overlayed in an uneditable box - when the user finishes spell checking the underlines disappear.

<script type="text/javascript">
    rapidSpell.ayt_aytEnabled = false;
    rapidSpell.ayt_staticMode = true;
</script>

Trigger the spell check using Javascript, eg. in a button click handler (in this call we pass 'this' so that the button's text can be changed to match spell check state);

<input type="button" onclick="rapidSpell.ayt_spellCheck(document.getElementById('textBox1'), this)" value="Spell Check" />

Changing UI text

To change the text used in alerts and the context menu, either set the GuiLanguage parameter or to change a specific text, call rapidSpell.ayt_setUIText(language, identifier, newText), eg;

<script type="text/javascript">
    rapidSpell.ayt_setUIText('ENGLISH', 'add', 'Add to dictionary');
</script>

The first argument specifies the language that is being changed (ie for the corresponding GuiLanguage parameter). The second argument specifies the label as follows:

ignore | Ignore once menu item text
ignoreAll | Ignore all menu item text
add | Add menu item text
edit | Edit menu item text (shown in static mode only)
changeAll | Change all menu item text
removeDuplicate | Remove duplicate menu item text
noSuggestions | 'No suggestions' menu item text
complete | Spell check complete


RapidSpell Web Java Documentation: Dialog Spell Checking

Dialog Spell Checking

All text boxes (within a form on the page) will be spell checked, unless specifically indicated to be ignored

  1. Ensure the RapidSpell servlet is registered in the web.xml (per 'Installation').
  2. Import RapidSpell-DIALOG.js to the page, using <script src="a.rapidspellweb?t=r&amp;n=RapidSpell-DIALOG.js"></script>
    a.rapidspellweb is the servlet registered in your web.xml - the scripts can also be used directly, see 'Installation'
  3. All textboxes (that are inside a FORM element, and have their id attribute set) will be checked when the user triggers the spell check eg. in a button click handler;

    <input type="button" onclick="rapidSpell.dialog_spellCheck()" value="Spell Check" />
//or for a specific text box
<input type="button" onclick="rapidSpell.dialog_spellCheck(true, 'textBoxID1')" value="Spell Check" />
//or for a list of specific text boxes
<input type="button" onclick="rapidSpell.dialog_spellCheck(true, ['textBoxID1', 'textBoxID2', ...])" value="Spell Check" />
If you receive Access Denied errors, add this code to your page (beneath the original src import):
<script type='text/javascript'>
    rapidSpell.dialog_popupURL ="<%=request.getContextPath()%>/a.rapidspellweb?t=d";
</script>
If that doesn't help, it may be a cross domain issue, please email support@keyoti.com

If accented characters and/or smart quotes (eg ’ or “ ”) appear as gibberish characters in the spell check window, it is because the spell checker is expecting the application encoding to be UTF-8. Avoid this by setting the assumed application encoding to the correct encoding (Tomcat defaults to 8859_1 for example):
<script type='text/javascript'>
    rapidSpell.setParameterValue('default', 'AssumedApplicationEncoding', '8859_1');
</script>
We cannot detect the application encoding, you must check the web.xml or any Filters for this.

Disabling spell check on specific text boxes

  • Add the attribute nospell="true" to the text box.
  • Or, add the (client) ID of text box to the Javascript array rapidSpell.ayt_ignoreTextBoxIds,
    eg. either 1 of
    rapidSpell.dialog_ignoreTextBoxIds[rapidSpell.dialog_ignoreTextBoxIds.length] = 'textBox1'; //where textBox1 is the id attribute of a textbox
rapidSpell.dialog_ignoreTextBoxIds[rapidSpell.dialog_ignoreTextBoxIds.length] = '<%= textBox1.id %>'; //where textBox1 is an object.

Modifying or removing the 'Add' option

Please see the user dictionary topic.

Setting field display labels

The dialog can show a label for which text field it is currently spell checking. To enable this, set the field display text (this must be done after the textboxes have been added to the DOM), eg.

    var oldload = onload;
    onload = function () {
        if (typeof oldload == 'function') oldload();
        rapidSpell.setParameterValue(document.getElementById('TextBox1'), 'FieldDisplayText', 'Text box 1');
        rapidSpell.setParameterValue(document.getElementById('TextBox2'), 'FieldDisplayText', 'Text box 2');
        rapidSpell.setParameterValue(document.getElementById('TextBox3'), 'FieldDisplayText', 'Text box 3');
    }

This code uses an override of window.onload, and because of that requires that we call any existing 'onload' functions. jQuery 'ready' handlers would not require this.

Using jQuery UI Dialog instead of a popup

In the Javascript for your page, call

rapidSpell.dialog_setUseDivDialog(true); //use false to deactivate
That will enable a DIV based dialog window, instead of a separate popup. The call to rapidSpell.dialog_setUseDivDialog checks if jQuery is currently loaded for the page (ie. your page already imports jQuery). If jQuery and/or jQuery UI is not present it will be loaded from CDN //code.jquery.com/jquery-1.11.3.min.js and //code.jquery.com/ui/1.11.4/jquery-ui.min.js. It is recommended (and to avoid using the CDN) that you please add jQuery and jQuery UI to your project and page, eg.
<link rel="stylesheet" href="/.../jquery-ui.css" />
<script src="/.../jquery-1.11.3.min.js"></script>
<script src="/.../jquery-ui.min.js"></script>

The jQuery UI Dialog mode uses an AJAX call to the "a.rapidspellweb" Servlet.

Modal mode

To display the spell check dialog modally, call

rapidSpell.dialog_setUseDivDialog(true);
rapidSpell.setServiceType('servlet');
rapidSpell.dialog_modal = true;

User options

There are several options available to the user via the "Options..." button in the dialog. Any changes to these options will override any settings specified in code. To disable the user options button (and any settings specified by the user), call

rapidSpell.setParameterValue('default', 'EnableOptions', false);

User options are stored in browser cookies and are not transferable to other devices as-is. Options apply to 'as you type' spell checking as well.

jQuery Dialog Troubleshooting

If you get '500' server errors, please check:

  • Use the F12 tool's Network tab, to record traffic to the Web Services. Inspect the response from the server for more detail about what is going wrong.

We don't want you to struggle, so please email support@keyoti.com if problems persist.


RapidSpell Web Java Documentation: Customizing RapidSpellWeb Layout

Customizing RapidSpellWeb Layout

It is possible to customize the layout of the spell checker using a HTML template mechanism. This is done by specifying the Layout.Html property with a string of HTML using special tags to indicate the position of the essential spell checker elements. The tags are <PreviewPane/>*, <AddButton/>, <IgnoreButton/>, <IgnoreAllButton/>, <UndoButton>, <FieldDisplayLabel/>, <ChangeButton/>, <ChangeAllButton/>, <FinishButton/>, <OptionsButton/>, <ChangeToLabel/>, <ChangeToBox/>*, <SuggestionsLabel/>, <SuggestionsBox/>* - tags marked with * are required for correct functionality.

Licensing

When you use the tag this way (on a server other than localhost), it has to be licensed with the licenseKey attribute, eg:

<RapidSpellWeb:rapidSpellWeb ... licenseKey="your license key">

Code Example With Customized Layout

Page containing the RapidSpellWeb control, note because this has different dimensions you should modify the dialog_width and dialog_height properties in the dialog parameters to 530 and 250 respectively, eg;
rapidSpell.dialog_width = 530; and rapidSpell.dialog_height = 250;

Put the code below into a JSP page and point the spell checker to it using rapidSpell.dialog_popupURL='path_to_file.jsp';

<%@ taglib uri="http://www.keyoti.com/" prefix="RapidSpellWeb" %>

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">

<html>

<title>Spell Check</title>

<body>

<RapidSpellWeb:rapidSpellWeb

changeToBoxStyle="font-size:10pt; width:200px; font-family:'arial,helvetica, sans-serif';"

changeToLabelStyle="font-size:9pt; font-family:'arial, helvetica, sansserif';"

suggestionsBoxStyle="font-size:10pt; width:200px; font-family:'arial,helvetica, sans-serif';"

suggestionsLabelStyle="font-size:9pt; font-family:'arial, helvetica, sansserif';"

previewPaneStyle="font-family: 'arial, sans-serif, helvetica'; font-size:8pt; font-weight:bold;"

previewPaneWidth="200"

previewPaneHeight="190"

ignoreButtonStyle="font-family:'Tahoma,Arial,Helvetica';font-size:10pt;border:1px solid #b5bed6; background-color:#dddddd; width: 90px;"

ignoreButtonOnMouseOver="this.style.backgroundColor='#b5bed6';this.style.borderColor='#08246b';"

ignoreButtonOnMouseOut="this.style.backgroundColor='#dddddd';this.style.borderColor='#b5bed6';"

finishButtonOnMouseOut="this.style.backgroundColor='#dddddd';this.style.borderColor='#b5bed6';"

layout="
        <table border=0>
        <tr><td colspan=3 bgcolor='#eeeeee'><b>MyCo Spell Checking</b>
        </td></tr><tr><td>
        <PreviewPane/>
        </td><td>
        <ChangeToLabel/>
        <br>
        <ChangeToBox/>
        <br>
        <SuggestionsLabel/>
        <br>
        <SuggestionsBox/>
        </td><td>
        <table border=0><tr><td>
<IgnoreButton/>

</td></tr><tr><td>

<IgnoreAllButton/>

</td></tr><tr><td>

<AddButton/>

</td></tr><tr><td>

<ChangeButton/>

</td></tr><tr><td>

<ChangeAllButton/>

</td></tr><tr><td>
<UndoButton/>
        </td></tr>
        <tr><td>
        <OptionsButton/>
        </td></tr>
<tr><td>
<FinishButton/>

        </td></tr></table>
        </td></tr></table>
"/>
</RapidSpellWeb:RapidSpellWeb>

</body>
</html>

The only restriction is that the special tags must be on a line by themselves.

For jQuery Dialog

If the jQuery Dialog is used (ie. if rapidSpell.dialog_setUseDivDialog(true); is called on the page), then the custom dialog is implemented by adding the UI elements to the page where the spell checker is used. An example of this is in the MVC demo project, under the RapidSpell install directory.

Code Example With Customized Layout
    <script type="text/javascript">
        rapidSpell.dialog_setUseDivDialog(true);
        rapidSpell.dialog_default_width = 500;
        rapidSpell.dialog_default_height= 350;
    </script>

    <style type='text/css'>
        #rsw_documentTextPanel
        {
            border: 1px solid #aaa;
            border-radius: 3px;
        }
            #rsw_word, #rsw_suggestions
        {
            border: 1px solid #aaa;
            border-top-color: #a0a0a0;
        }
        #rsw_optionsDialog
        {

            display: none;
            position: absolute;
            margin-left: auto;
            margin-right: auto;
            margin-top: auto;
            margin-bottom: auto;
            left: 0;
            right: 0;
            top: 0;
            bottom: 0;
            width: 295px;
            height: 230px;
            z-index: 101;
            background-color: white;
            border: 1px solid #444;
            border-radius: 5px;
            padding: 8px;
        }
        #rsw_optionsDialog_Backing
        {
            display: none;
            position: absolute;
            margin-left: auto;
            margin-right: auto;
            margin-top: auto;
            margin-bottom: auto;
            left: 0;
            right: 0;
            top: 0;
            bottom: 0;
            width: 100%;
            height: 100%;
            background-color: rgba(100,100,100,.60);
            z-index: 100;
        }
        #rsw_optionsDialog > label
        {
            display: block;
            padding-bottom: 12px;

        }
        #rsw_optionsDialog > input
        {
            margin-right: 9px;
            margin-top:12px;
        }
        #rsw_optionsHeader
        {
            font-size: 1.2em;
            border-bottom: 1px solid #aaa;
        }

        #rsw_documentTextPanel
        {
            border: 1px solid #aaa;
            border-radius: 3px;

            text-align: justify;
            padding:4px;
            overflow-y:scroll;
            margin-bottom:4px;
        }

        .badWordHighlight{
            background-position: bottom;background-repeat: repeat-x;background-color: #ededff;

        }
        #rsw_documentTextPanel{

            height: 150px;
        }

        #rsw_changePanel{

            width: 200px;
            float:left;
        }

        #rsw_buttonPanel{
            width:250px;
            float:right;

        }

        #rsw_buttonPanel  div, #rsw_buttonPanel input{
            margin-right:0px;
            width:100px;
            font-size:9pt;
        }

        #rsw_optionsButton
        {
            font-size:9pt;
        }
         #rsw_dialog input, #rsw_dialog select {
            margin:4px;
         }

         #rsw_buttonPanel input{
            margin: 10px;
        }

        #rsw_dialog
        {
            font-family:'Segoe UI', Arial, sans-serif;
            font-size:10pt;
            padding:10px;
            z-index:500;
        }

        #rsw_word
        {
            width:197px;
        }

         #rsw_suggestions
        {
            width:200px;
        }

        #rsw_fdtl
        {
            line-height:24px;
        }
        </style>

        ....

    <div id="rsw_dialog" nospell="true" title="Custom Spell Check" style="display:none;">
        <form id="spellCheckerForm" onsubmit="rsw_change(); return false;">
            <div id="rsw_fdtl"></div>
            <div id="rsw_documentTextPanel">
            </div>
            <div id="rsw_changePanel">
                <label for="rsw_word"><span>Change To:</span></label>
                <input name="rsw_word" type="text" id="rsw_word" size="16" tabindex="4" />
                <label for="rsw_suggestions"><span>Suggestions:</span></label>
                <select name="rsw_suggestions" id="rsw_suggestions" size="6" onchange="rsw_changeSuggestions()" ondblclick="rsw_change()" tabindex="5">
                    <option value="No Suggestions.">No Suggestions.</option>
                </select>

            </div>
            <div id="rsw_buttonPanel">
                <div style="display: inline-block;">
                    <input type="button" value="Ignore" id="rsw_ignoreButton" onclick="rsw_ignoreCurrent()" tabindex="1"  name="rsw_ignoreButton" />
                    <input type="button" value="Ignore All" id="rsw_ignoreAllButton" onclick="    rsw_ignoreAllInstances()" tabindex="2"  name="rsw_ignoreAllButton" />
                    <input type="button" value="Add" id="rsw_addButton" onclick="rsw_addCurrent()" tabindex="3" name="rsw_addButton" />
                    <input type="button" value="Options..." id="rsw_optionsButton" onclick="rsw_showOptions()" tabindex="10" name="rsw_optionsButton" />
                </div>
                <div style="display: inline-block;">
                    <input type="button" value="Change" id="rsw_changeButton" onclick="    rsw_change()" tabindex="6" name="rsw_changeButton" />
                    <input type="button" value="Change All" id="rsw_changeAllButton" onclick="    rsw_changeAll()" tabindex="7"  name="rsw_changeAllButton" />
                    <input type="button" value="Undo" id="rsw_undoButton" onclick="    rsw_undoChange()" tabindex="8" name="rsw_undoButton" />
                    <input type="button" value="Finish" id="rsw_cancelButton" onclick="    rsw_finish(true)" tabindex="9"  name="rsw_cancelButton" />
                </div>

            </div>
        </form>
        <div id="rsw_optionsDialog">
            <h1 id="rsw_optionsHeader">Basic Settings</h1>
            <label>
                <input type="checkbox" id="IgnoreCapitalizedWords"/>Ignore words in UPPERCASE</label>
                <label><input type="checkbox" id="IgnoreWordsWithDigits"/>Ignore words with numbers</label>
                <label><input type="checkbox" id="IgnoreURLsAndEmailAddresses"/>Ignore internet addresses and emails</label>
                <label><input type="checkbox" id="IgnoreCase"/>Ignore improper case (eg. "australia", "tABle")'</label>
                <input type="button" value="OK" onclick="    rsw_saveOptions()"/>
                <input type="button" value="Cancel" onclick="    rsw_cancelOptions()"/></div>
        <div id="rsw_optionsDialog_Backing"></div>
    </div>

When a DIV with id=rsw_dialog is included on the page, it is assumed that this will contain all the necessary UI elements, and this will be used instead of generating new ones. In order to hide elements (such as buttons), it is recommended that they are hidden with display:none (CSS) rather than removed from the HTML markup (as this could cause Javascript errors).


RapidSpell Web Java Documentation: User Dictionary

User Dictionary

Location and per user dictionaries

By default the user dictionary will be stored at ~/user-dictionary.txt (where ~/ means the web application root*). However this should ideally be changed to give each user their own dictionary.

  • In Javascript, call rapidSpell.setParameterValue('default', 'UserDictionaryFile', newPath) - where newPath is a string with the user dictionary path.
  • To give each user their own dictionary (recommended) set the newPath based on the user's ID, eg. var newPath = "<%= currentUserObject.Id %>" (or similar).
  • The 'default' argument means change this parameter for all text boxes, but it can instead be the textbox object (not id) that the parameter should apply to, see 'Parameters'.

Setting The Storage Directory Path

As a security measure, RapidSpell locks down user dictionary storage to locations specified in the application's web.xml file, and only allows files of type .txt to be used as user dictionaries.

1. Set a paramter called RapidSpellUserDictionaryDirs in web.xml to a comma delimited list of directories where you intend to store user dictionary files.

eg.

<?xml version="1.0" encoding="UTF-8"?>

<web-app ...>

    <context-param>
        <param-name>RapidSpellUserDictionaryDirs</param-name>
        <param-value>~/</param-value>
    </context-param>

....
</web-app>

This will mean that userDictionaryFile in the tags must be set to a file under ~/ (ie. web application root*).
It may be necessary to restart the app. server after changing the web.xml, for it to have effect.

2. User dictionaries must now be .txt files, so with the above setting a valid userDictionaryFile value is "~/somename.txt"

* Please note that in some server contexts (such as WAR files that are not 'exploded' on deployment) we may not be able to automatically resolve '~/' to the application root, in this case please set the param RapidSpellBaseDir.
<context-param>
        <param-name>RapidSpellBaseDir</param-name>
        <param-value>c:\path\to\app root\</param-value>
</context-param>

Disabling 'Add'

  • As above, set the dictionary path to an empty string; rapidSpell.setParameterValue('default', 'UserDictionaryFile', '');


RapidSpell Web Java Documentation: 3rd Party Textboxes

3rd Party Textboxes

Static inline spell checking

As you type is not enabled for 3rd party or HTML editors. Generally, to use the static inline spell check, setup spell checking as usual but launch the spell check with rapidSpell.ayt_spellCheck('text box id'), where the text box id is the ID of the editable element - if this is not found the spell checker will look for an editable element.

Dialog spell checking

Generally, to use the dialog spell check, setup spell checking as usual but launch the spell check with rapidSpell.dialog_spellCheck('text box id'), where the text box id is the ID of the editable element - if this is not found the spell checker will look for an editable element.

Examples

Single CKEditor, Multiple CKEditors
Single TinyMCE, Multiple TinyMCEs
KendoUI Editor
Single CKEditor Example (inline & dialog modes)

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <script src="/ckeditor_files/ckeditor.js" type="text/javascript"></script>
    <script src="a.rapidspellweb?t=r&n=RapidSpell-AYT.js"></script>
    <script src="a.rapidspellweb?t=r&n=RapidSpell-DIALOG.js"></script>

<script type="text/javascript">

    rapidSpell.ayt_staticMode = true;
    rapidSpell.ayt_aytEnabled = false;

    function spell(id, mode) {
        rapidSpell.setParameterValue('default', 'IgnoreXML', true);
        var ifr = document.getElementsByClassName('cke_wysiwyg_frame cke_reset')[0];
        ifr.setAttribute('id', id+'_ifr');
        ifr.id = id+'_ifr';

        if (mode == 'inline')
            rapidSpell.ayt_spellCheck(id + '_ifr')
        else {

            rapidSpell.dialog_spellCheck(true, id + '_ifr')
        }
    }

    window.onload = function () {

        var editor = CKEDITOR.replace('editor1');

        editor.addCommand("inlineSpellCommand", { // create named command
            exec: function (edt) {
                spell('editor1', 'inline');
            }
        });

        editor.addCommand("dialogSpellCommand", { // create named command
            exec: function (edt) {
                spell('editor1', 'dialog');
            }
        });

        editor.ui.addButton('SpellInlineButton', { // add new button and bind our command
            label: "Click me",
            command: 'inlineSpellCommand',
            toolbar: 'insert',
            icon: '/AYT/abc.png'
        });
        editor.ui.addButton('SpellDialogButton', { // add new button and bind our command
            label: "Click me",
            command: 'dialogSpellCommand',
            toolbar: 'insert',
            icon: '/AYT/abc.png'
        });

        /*If you are going to do this and you want to use a custom toolbar out of your config it's not going to work unless you add 'SpellInlineButton' and 'SpellDialogButton' to your custom toolbar.*/
    }

</script>
</head>
<body>
<form>
<textarea name="editor1"><p>Initial value.</p></textarea>
<input type="button" onclick="spell('editor1', 'inline')" value = 'Inline spell check' />
<input type=button onclick="spell('editor1', 'dialog')" value='Dialog spell check' />
</form>
</body>
</html>
The part in bold adds an id attribute to the CKEditor's iframe, to make it easier for the spell checker to access it.

Single TinyMCE Example (inline & dialog modes)

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head id="Head1" runat="server">

    <!-- CDN hosted by Cachefly -->
    <script type="text/javascript" src="http://tinymce.cachefly.net/4.0/tinymce.min.js"></script>
    <script src="a.rapidspellweb?t=r&n=RapidSpell-AYT.js"></script>
    <script src="a.rapidspellweb?t=r&n=RapidSpell-DIALOG.js"></script>

    <script type="text/javascript">
        tinymce.init({
            height: 160,
            selector: 'textarea',
            toolbar: "insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image | mybutton1 mybutton2",
            setup: function (ed) {
                // Add a custom button for inline check
                ed.addButton('mybutton1', {
                    title: 'Inline spell check',
                    context: "tools",
                    image: '../images/abc.png',
                    onclick: function () {
                        rapidSpell.ayt_spellCheck('mytextbox_ifr');
                    }
                });
                // Add a custom button for dialog check
                ed.addButton('mybutton2', {
                    title: 'Dialog spell check',
                    context: "tools",
                    image: '../images/abc.png',
                    onclick: function () {
                        rapidSpell.setParameterValue(document.getElementById('mytextbox_ifr'), 'IgnoreXML', true);
                        rapidSpell.dialog_spellCheck(true, 'mytextbox_ifr');
                    }
                });
            }
        });
        rapidSpell.ayt_staticMode = true;
        rsw_absolutePositionStaticOverlay = true;

    </script>
    <title></title>
    <style type="text/css">
       .oldBrowserBox, .oldBrowserBox *
        {
           font-size: 11px !important;
           font-family:Verdana,Arial,Helvetica,sans-serif !important;
        }
</style>
</head>
<body>
        <textarea id='mytextbox' name="S1" ></textarea>
</body>
</html>

Multiple CKEditor Example (inline & dialog modes)

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <script src="/ckeditor_files/ckeditor.js" type="text/javascript"></script>
    <script src="a.rapidspellweb?t=r&n=RapidSpell-AYT.js"></script>
    <script src="a.rapidspellweb?t=r&n=RapidSpell-DIALOG.js"></script>

<script type="text/javascript">
    //if you have jquery you can use $.inArray
    if (!Array.indexOf)
    {
      Array.indexOf = [].indexOf ?
          function (arr, obj, from) { return arr.indexOf(obj, from); }:
          function (arr, obj, from) { // (for IE6)
            var l = arr.length,
                i = from ? parseInt( (1*from) + (from<0 ? l:0), 10) : 0;
            i = i<0 ? 0 : i;
            for (; i<l; i++) {
              if (i in arr  &&  arr[i] === obj) { return i; }
            }
            return -1;
          };
    }

    var ckControls = ['editor1', 'editor2'];
    rapidSpell.ayt_staticMode = true;
     rapidSpell.ayt_aytEnabled = false;
    var inlineSpellMode=false;

    function spell(mode) {
        //give un-id'd textboxes an id
        var idsToCheck = [];
        var textareas = document.getElementsByTagName("textarea");
        var inputs = document.getElementsByTagName("input");
        for (var i = 0; i < textareas.length; i++){
            if(ckControls.indexOf(textareas[i].name)==-1)//not a CK textbox, so treat like a regular textarea
            {
                if (textareas[i].id == ''){
                          textareas[i].setAttribute('id', textareas[i].name+i);
                          textareas[i].id = textareas[i].name+i;
                }

                idsToCheck[idsToCheck.length] = textareas[i].id;
            }
        }
        for (var i = 0; i < inputs.length; i++){
            if(ckControls.indexOf(inputs[i].name)==-1)//not a CK textbox, so treat like a regular input
            {
                if (inputs[i].type == 'text' && inputs[i].id == ''){
                          inputs[i].setAttribute('id', inputs[i].name+i);
                          inputs[i].id = inputs[i].name+i;
                }

                if(inputs[i].type == 'text')
                    idsToCheck[idsToCheck.length] = inputs[i].id;
            }
        }

        var ifrs = document.getElementsByClassName('cke_wysiwyg_frame cke_reset');
        for(var i=0; i<ifrs.length; i++){
            var ifr = ifrs[i];
            ifr.setAttribute('id', i+'_ifr');
            ifr.id = i+'_ifr';
            rapidSpell.setParameterValue(ifr, 'IgnoreXML', true);
            idsToCheck[idsToCheck.length] = ifr.id;
        }

        if (mode == 'inline'){
            inlineSpellMode = !inlineSpellMode;
            if(inlineSpellMode)
                rapidSpell.ayt_setupTextBoxes(false, idsToCheck);
            rapidSpell.ayt_spellCheck();
        }else {

            rapidSpell.dialog_spellCheck(true, idsToCheck);
        }
    }

    window.onload = function () {
        for(var i=0; i<ckControls.length; i++){
            CKEDITOR.replace(ckControls[i]);
        }
    };

    </script>
    </head>
    <body>
    <form>
    <textarea name="editor1"><p>Initifal value.</p></textarea>
    <textarea name="editor2"><p>Subseequent value.</p></textarea>
    <textarea name="ta" >helllo worlkd</textarea>
    <input type="button" onclick="spell('inline')" value = 'Inline spell check' />
    <input type=button onclick="spell('dialog')" value='Dialog spell check' />

</form>
</body>
</html>
The part in bold adds an id attribute to the CKEditor's iframe, to make it easier for the spell checker to access it.

Multiple TinyMCE Example (inline & dialog modes)

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head id="Head1" runat="server">

    <!-- CDN hosted by Cachefly -->
    <script type="text/javascript" src="http://tinymce.cachefly.net/4.0/tinymce.min.js"></script>
    <script src="a.rapidspellweb?t=r&n=RapidSpell-AYT.js"></script>
    <script src="a.rapidspellweb?t=r&n=RapidSpell-DIALOG.js"></script>

    <script type="text/javascript">
            rapidSpell.ayt_staticMode=true;
            rapidSpell.ayt_aytEnabled = false;
            rapidSpell.setParameterValue('default', 'IgnoreXML', true);

            tinymce.init({selector:'textarea'});

            function inlineCheck(){
                rapidSpell.ayt_setupTextBoxes(false, ['ta1_ifr', 'ta2_ifr']);
                rapidSpell.ayt_spellCheck();
            }
    </script>

    <style type="text/css">
           .oldBrowserBox, .oldBrowserBox *
            {
               font-size: 11px !important;
               font-family:Verdana,Arial,Helvetica,sans-serif !important;
            }
    </style>

    </head>
    <body>
    <textarea id="ta1">Helloo worldd...
    </textarea>
    <textarea id="ta2">niice to meet yuo.
    </textarea>
    <input type="button" onclick="inlineCheck()" value="Inline spell">
    <input type='button' onclick="rapidSpell.dialog_spellCheck(true, ['ta1_ifr', 'ta2_ifr'])" value="Dialog spell"/>
</body>
</html>

KendoUI Editor Example (inline & dialog modes)

This example assumes the same folder structure as the examples in the KendoUI download. The spell functions find the editor's IFRAME and assign an ID to it so that the spell checker can reference it.

<!DOCTYPE html>
<html>
<head>
    <title>Basic usage</title>
    <meta charset="utf-8">
    <link href="../content/shared/styles/examples-offline.css" rel="stylesheet">
    <link href="../../styles/kendo.common.min.css" rel="stylesheet">
    <link href="../../styles/kendo.rtl.min.css" rel="stylesheet">
    <link href="../../styles/kendo.default.min.css" rel="stylesheet">
    <link href="../../styles/kendo.default.mobile.min.css" rel="stylesheet">
    <script src="../../js/jquery.min.js"></script>
    <script src="../../js/jszip.min.js"></script>
    <script src="../../js/kendo.all.min.js"></script>
    <script src="../content/shared/js/console.js"></script>
    <script src="a.rapidspellweb?t=r&n=RapidSpell-AYT.js"></script>
    <script src="a.rapidspellweb?t=r&n=RapidSpell-DIALOG.js"></script>
    <style type="text/css">
        .oldBrowserBox, .oldBrowserBox * {
            font-size: 12px !important;
            font-family: Verdana,Geneva,Arial,Helvetica,sans-serif !important;
        }
    </style>

</head>
<body>

        <div id="example">
                <textarea id="editor" rows="10" cols="30" style="height:440px">
                    &lt;p&gt;&lt;img src=&quot;../content/web/editor/kendo-ui-web.png&quot; alt=&quot;Editor for ASP.NET MVC logo&quot; style=&quot;display:block;margin-left:auto;margin-right:auto;&quot; /&gt;&lt;/p&gt;
                    &lt;p&gt;
                        Kendo UI Editor allows your users to edit HTML in a familiar, user-friendly way.&lt;br /&gt;
                        In this version, the Editor provides the core HTML editing engine, which includes basic text formatting, hyperlinks, lists,
                        and image handling. The widget &lt;strong&gt;outputs identical HTML&lt;/strong&gt; across all major browsers, follows
                        accessibility standards and provides API for content manipulation.
                    &lt;/p&gt;
                    &lt;p&gt;Features include:&lt;/p&gt;
                    &lt;ul&gt;
                        &lt;li&gt;Text formatting &amp; alignment&lt;/li&gt;
                        &lt;li&gt;Bulleted and numbered lists&lt;/li&gt;
                        &lt;li&gt;Hyperlink and image dialogs&lt;/li&gt;
                        &lt;li&gt;Cross-browser support&lt;/li&gt;
                        &lt;li&gt;Identical HTML output across browsers&lt;/li&gt;
                        &lt;li&gt;Gracefully degrades to a &lt;code&gt;textarea&lt;/code&gt; when JavaScript is turned off&lt;/li&gt;
                    &lt;/ul&gt;
                    &lt;p&gt;
                        Read &lt;a href=&quot;http://docs.telerik.com/kendo-ui&quot;&gt;more details&lt;/a&gt; or send us your
                        &lt;a href=&quot;http://www.telerik.com/forums/&quot;&gt;feedback&lt;/a&gt;!
                    &lt;/p&gt;
                </textarea>
            <script>
                $(document).ready(function () {

                    //rapidSpell.ayt_staticMode = true;
                    // create Editor from textarea HTML element with default set of tools
                    var e = $("#editor").kendoEditor({ resizable: {
                        content: true,
                        toolbar: true
                    }
                    });

                    rapidSpell.setParameterValue('default', 'IgnoreXML', true);
                    rapidSpell.ayt_staticMode = true;
                    rapidSpell.ayt_aytEnabled = false;
                    rapidSpell.dialog_setUseDivDialog(true);
                    rapidSpell.dialog_modal = true;
                });

                function inlineSpell(editorId) {
                    var ed = $("#" + editorId).prev('iframe')[0];
                    ed.setAttribute('id', editorId + "_IFRAME");
                    rapidSpell.ayt_spellCheck(editorId+'_IFRAME')
                }

                function dialogSpell(editorId) {
                    var ed = $("#" + editorId).prev('iframe')[0];
                    ed.setAttribute('id', editorId + "_IFRAME");
                    rapidSpell.dialog_spellCheck(true, editorId);
                }
            </script>
        </div>

    <input type="button" onclick="inlineSpell('editor')" value="Inline spell check"/>
    <input type="button" onclick="dialogSpell('editor')" value="Dialog spell check" />

</body>
</html>

Custom text interface

In cases where the automatic text retrieval interface does not return the correct text to be spell checked, from the textbox, it is possible to define a custom interface. The custom interface is a simple class that gets and sets the text in the textbox.

For example, add the code below to the page - the getText function is called by the spell checker when text is needed to be spell checked, and the setText function is called by the spell checker when spell check has finished and the text needs to be set back in the textbox.

//textBoxId is the textbox to be spell checked
//mode is either 'dialog' or 'ayt', indicating the type of spell check occurring
rapidSpell.textInterfaceNeeded =  function (textBoxId, mode) {return new RSCustomInterface(textBoxId);}

function RSCustomInterface(tbElementName){
    this.tbName = tbElementName;
    this.getText = getText;
    this.setText = setText;
    function getText(){
        //return the text from the text component named this.tbName,
        //this may be HTML formatted text
        return document.getElementById(this.tbName).innerHTML;
    }
    function setText(text){
        //set the text in the text component to the text argument
        //this may be HTML formatted text

        document.getElementById(this.tbName).innerHTML = text;

    }
}


RapidSpell Web Java Documentation: Parameters

Parameters

Operational settings

These settings relate to how RapidSpell operates, rather than how the spell checker processes text, call any of the following lines to set the parameter

  • rapidSpell.ayt_aytEnabled = true;
    whether to do as-you-type checking.
  • rapidSpell.ayt_staticMode = false;
    whether to do static, button operated overlays with underlines.
  • rapidSpell.ayt_recheckDelay = 500;
    how many milliseconds to wait after the user stops typing to do the spell check.
  • rapidSpell.dialog_popupURL = "/path/popup.jsp";
    specifies the URL where popup.jsp resides, by default this is automatically determined.
  • rapidSpell.dialog_modal = false;
    whether the popup will be modal.
  • rapidSpell.dialog_width = 370;
    popup width.
  • rapidSpell.dialog_height = 430;
    popup height.
  • rapidSpell.dialog_left = 100;
    X coordinate of the popup.
  • rapidSpell.dialog_top = 100;
    Y coordinate of the popup.

Spell checker settings

These settings affect user experience, such as how the spell checker processes text, dictionaries and appearance etc.

Setting default parameter values for all text boxes on a page

In Javascript, call rapidSpell.setParameterValue('default', parameterName, value);

Parameters
  • UserDictionaryFile
    see example
  • SuggestionsMethod
    PHONETIC_SUGGESTIONS or HASHING_SUGGESTIONS (default)
  • SeparateHyphenWords
    whether to treat hyphenated (-) words as separate words, default is false.
  • IncludeUserDictionaryInSuggestions
    whether the user dictionary should be used in finding suggestions for misspelt words, default is false.
  • IgnoreXML
    whether to ignore XML/HTML tags, false by default.
  • IgnoreCapitalizedWords
    whether to ignore words with capital letters, false by default.
  • GuiLanguage
    the UI language "ENGLISH", "FRENCH", "SPANISH", "GERMAN", "ITALIAN", "PORTUGUESE", "DUTCH", or "POLISH".
  • LanguageParser
    parser for current dictionary "ENGLISH", "FRENCH", "SPANISH", "GERMAN", "ITALIAN", "PORTUGUESE", "DUTCH", or "POLISH".
  • AllowAnyCase
    Whether to allow words spelt with incorrect case, eg. "africa", instead of "Africa", this is more relaxed than AllowMixedCase, default is false.
  • IgnoreWordsWithDigits
    whether to ignore words with numbers in them (eg. A10 or 7-11), true by default.
  • ShowFinishedMessage
    whether to show the popup dialog at the end of the spell check.
  • ShowNoErrorsMessage
    whether to show the popup dialog stating there were no spelling errors.
  • AllowMixedCase
    whether to allow words spelt with mixed case, eg. "MIxEd", default is false.
  • WarnDuplicates
    whether to treat duplicate words as errors (eg. "this is is an error"), true by default.
  • DictFile
    main dictionary (.dict) file path on the server (optional).
  • ConsiderationRange
    the size factor for words to consider for suggestions, lower values are faster but consider less words for suggestions. Default is 80. If w <= 1 this method won't do anyting.
  • LookIntoHyphenatedText
    whether to 'look into' text with hyphens (-), if the word has hyphens in it and LookIntoHyphenatedText is set true (default), the parts of the text around the hyphens will be checked individually.
  • CheckCompoundWords
    whether to check for compound words, setting this to true is essential for languages such as German which allow for compound words.
  • EnableUndo
    whether to provide 'undo' functionality to the user
    when checking very large texts this may cause browser memory issues.
  • LeaveWindowOpenForUndo
    whether to leave the popup open after the last word so that the user can undo the last operation.
  • IgnoreURLsAndEmailAddresses
    whether to ignore URLs and email addresses, true by default.
  • SuggestSplitWords
    whether to look for connected words in suggestions, true by default.
  • FindCapitalizedSuggestions
    whether to look for capitalized suggestions (when the error isn't capitalized), note this will slow FindSuggestions down by about 7 times.

Setting parameter values for a specific text box on the page

Call rapidSpell.setParameterValue(textBox, parameterName, value);
where 'textBox' is the text box element object (as returned by document.getElementById(textBoxId)). This will set the parameter for spell checking on that text box only, all other text boxes will use the default parameter values.


RapidSpell Web Java Documentation: AJAX & DHTML Type Usage

AJAX & DHTML Type Usage

Starting from the regular as you type setup. If textboxes on the page are being added/removed via Javascript (this covers DHTML and also AJAX type usage), then it is necessary to call a Javascript function in RapidSpell to make it rescan for active textboxes to spell check.

rapidSpell.ayt_setupTextBoxes(true);

Example using (generic) tabs

On a page using a tabs add a client side event handler for the tab changed event

<script type="text/javascript">
        function tabContainer_TabChanged() {
            rapidSpell.ayt_setupTextBoxes(true);
        }
</script>

...

The spell checker will then refresh and underline the errors in the new textboxes.


RapidSpell Web Java Documentation: Client Scripting With RapidSpell

Client Scripting With RapidSpell

The 'rapidSpell' object can be used to code against, it is created automatically when the page loads and does not need to be declared or created manually.

Inline spell checking

Text box scripting

Although inline spell checked text boxes are actually IFRAMEs (unless in static mode in which case they remain HTML text boxes), client scripting is the same; the onaction event handlers work and the .value property can be set.

Cancelling UI events (eg. keypress)

To cancel events, such as keypress, for example to inhibit characters being added to a text box, handle the event and call rsw_activeTextbox.preventDefaultCurrentEvent(); to cancel the event.

For example to prevent characters like #, ' and \

            document.getElementById('tb1').onkeypress = function (e) {
                var vRestrictedChars = [34, 35, 38, 39, 92, 220, 222];
                var k = e.which;
                if ((vRestrictedChars.indexOf(k) >= 0)) {
                    e.preventDefault();
                    e.cancelBubble = true;
                    e.returnValue = false;
                    rsw_activeTextbox.preventDefaultCurrentEvent();
                }
            };

Spell checker

Events

The spell checker fires certain events, which can be attached to via the addEventListener function, and removed from via removeEventListener(eventName, listenerFunction).

rapidSpell.addEventListener('ayt_textboxesinitialized', onInitialized);
rapidSpell.addEventListener('ayt_spellcheckfinish',  onFinish);
rapidSpell.addEventListener('ayt_correction',  onCorrection);
rapidSpell.addEventListener('ayt_contextmenushowing',  onMenuShowing);
rapidSpell.addEventListener('ayt_contextmenushown',  onMenuShown);
//Other events are; ayt_finished_initializing, contextmenu.

...

//called when the textboxes are ready for user input
function onInitialized() {...}

//called when spell check response comes from the server, the id of the textbox can be obtained
//from textbox.shadowTB.id (for non static mode)
function onFinish(textbox, complete, numberOfErrors){...}

//called when a correction is made the id of the textbox can be obtained from textbox.shadowTB.id
//(for non static mode), and data.errorWord has the error word, and data.replacement has the correction
function onCorrection(textbox, data) {...}

//called when the context menu is about to be shown
//contextMenu is the context menu object, it includes .x and .y fields with it's position
//activeTextbox is our internal class for the textbox, you might find something useful by browsing it's variables in your IDE
//event the mouse/keyboard user event that caused the menu to be shown
//spellingErrorElement is a span tag that is highlighting the error, usually it's the position of this where the menu should be shown
function onMenuShowing(contextMenu, activeTextbox, event, spellingErrorElement ){...}

//called when the context menu has been shown
function onMenuShown(contextMenu, activeTextbox, event, spellingErrorElement ){...}
Functions
  • rapidSpell.ayt_spellCheck(document.getElementById('TextBox1'), this) - spell check 'TextBox1' (this allows the spell checker to modify the button text)
  • rapidSpell.ayt_spellCheck() - spell check all text boxes (that are not setup to be ignored)
  • rapidSpell.ayt_setupTextBoxes(true) - call this when textboxes are added to or removed from the page (eg. with AJAX or DHTML)
  • rapidSpell.ayt_refreshUnderlines() - respell checks the text boxes, call this when changing spell check parameters
  • rapidSpell.setParameterValue() - see 'Parameters'
  • rapidSpell.getParameterValue() - see 'Parameters'
Fields
  • rapidSpell.ayt_helperURL - the URL of the page holding the RapidSpellWInlineHelper control, by default this is in the same folder as the RapidSpell-AYT.js script
  • rapidSpell.ayt_aytEnabled - whether to spell check as the user types (true)
  • rapidSpell.ayt_staticMode - whether to spell check statically (user cannot edit text) (false)
  • rapidSpell.ayt_recheckDelay - number of milliseconds user must pause (in as you type mode) before spell check occurs (500)
  • rapidSpell.ayt_ignoreTextBoxIds - array of text box ids to not spell check

Dialog spell checking

Spell checker

Events

The spell checker fires certain events, which can be attached to via the addEventListener function, and removed from via removeEventListener(eventName, listenerFunction).

rapidSpell.addEventListener('dialog_finishedcheckingtextbox', onFinish);
rapidSpell.addEventListener('dialog_correction',  onCorrection);
//Other events available are; dialog_finishedcheckingall, dialog_finishedcheckingtextbox, dialog_startedcheckingtextbox, dialog_correction, dialog_add

...

//called when spell check on a text box finishes, the id of the textbox can be obtained
//from textbox.id, complete indicates if it was completed or cancelled (false)
function onFinish(src, textbox, complete){...}

//called when a correction is made the id of the textbox can be obtained from textbox.id
//wordStart is where the error occurs in the text, oldWord is the error and newWord is the correction
function onCorrection(src, textbox, wordStart, oldWord, newWord) {...}
Functions
  • rapidSpell.dialog_spellCheck(true, textBoxID) - spell check text box with ID 'textBoxID'
  • rapidSpell.dialog_spellCheck(true) - spell check all text boxes *that are not setup to be ignored)
  • rapidSpell.setParameterValue() - see 'Parameters'
  • rapidSpell.getParameterValue() - see 'Parameters'
Fields
  • rapidSpell.dialog_popupURL - the URL of the page holding the RapidSpellWeb control, by default this is in the same folder as the RapidSpell-DIALOG.js script
  • rapidSpell.dialog_modal - modal popup
  • rapidSpell.dialog_width - width of the popup
  • rapidSpell.dialog_height - height of the popup
  • rapidSpell.dialog_left - X coord position of the popup
  • rapidSpell.dialog_top - Y coord position of the popup
  • rapidSpell.dialog_ignoreTextBoxIds - array of text box ids to not spell check


RapidSpell Web Java Documentation: AJAX Based Programmatic String Checking

AJAX Based Programmatic String Checking (RapidSpellCheckerClient)

Setup

  1. Ensure the RapidSpell servlet is registered in the web.xml (per 'Installation').
  2. Import RapidSpell-AYT.js to the page, using <script src="a.rapidspellweb?t=r&amp;n=RapidSpell-AYT.js"></script>
    a.rapidspellweb is the servlet registered in your web.xml - the scripts can also be used directly, see 'Installation'
  3. Instantiate the object.
    var rsc = new RapidSpellCheckerClient(rapidSpell.ayt_helperURL);

Asynchronously spell checking a string

Generally we recommend that spell checking be performed asynchronously, as this allows the UI to respond to user events. Asynchronous functions are non blocking, so the return is handled by a callback function. Using asynchronous functions can be awkward, so we also provide a synchronous version, below. This asynchronous method is available in browsers that support XmlHttpRequst (eg. IE, FF...) and also in older browsers which don't (eg Opera 6).

rsc.Check(textToCheck, display);

'display' is the name of a function that will handle the call back and process the result. See below.

Synchronously spell checking a string

This form is used to run the spell check synchronously. This will cause the UI to block while the browser waits for the response. Under good network conditions this should be acceptable. One warning about this synchronous method is that it is only available in browsers capable of XmlHttpRequest (AJAX calls). If the browser cannot process these then the asynchronous method should be used instead.

var result = rsc.Check(textToCheck);

Processing the result

The result is an object with the following properties.

originalText //The text that was spell checker
numberOfErrors //The number of spelling errors
errorPositionArray //An array of errors, with their positions and suggestions

errorPositionArray[n].start //Where the spelling error is in the original text
errorPositionArray[n].end //Where the spelling error ends
errorPositionArray[n].suggestions //Simple array of string suggestions

The result object, which is returned by Check in synchronous calls, or passed to the call-back function in asynchronous calls, can then be processed.

function display(result){
    var resultTB = document.getElementById("resultTB");

    resultTB.value = '"' + result.originalText + "\" has " + result.numberOfErrors + " errors\r\n\r\n";
    for(var e = 0; e<result.errorPositionArray.length; e++){
        resultTB.value += "Error "+e+": " + result.errorPositionArray[e].word + "\r\n";
        resultTB.value += "\tstart:"+result.errorPositionArray[e].start+"\r\n";
        resultTB.value += "\tend:"+result.errorPositionArray[e].end+"\r\n";
        resultTB.value += "\tsuggestions: " + (result.errorPositionArray[e].suggestions.length==0?"none":"") + "\r\n";
        for(var s = 0; s<result.errorPositionArray[e].suggestions.length; s++){
            resultTB.value += "\t\t" + result.errorPositionArray[e].suggestions[s] + "\r\n";
        }
        resultTB.value += "\r\n";
    }
}

Add a word to user dictionary

Adding to the user dictionary is always asynchronous and requires the UserDictionaryFile property to be set to a file path on the server where the dictionary will be stored.

rsc.AddWord(wordToAdd);

Setting properties

Spell check options can be set on the server through the Control properties or on the client side through the Javascript functions.

rsc.setParameterValue(optionName, value);

where optionName is the name as specified exactly in the Control serverside properties. Similarly property values can be obtained through

rsc.getParameterValue(optionName);

Please consult the product demos for a complete example, plus how to access parameter names programmatically.


RapidSpell Web Java Documentation: GWT (Google Web Toolkit) Usage

GWT Usage

Javascript based usage is compatible with GWT (follow the instructions in this section of the help), however inline/as-you-type spell checking with GWT also requires that you call

rapidSpell.ayt_setupTextBoxes(true);
in Javascript, once GWT is initialized, i.e. from onModuleLoad in an EntryPoint class.


RapidSpell Web Java Documentation: Examples (Dialog/PopUp Spell Checker)

Examples (Dialog/PopUp Spell Checker)

Below are some use scenarios of the 2 spell checker components supplied, please refer to the API documentation for additional detail.


RapidSpell Web Java Documentation: Simple Popup Spell Checking

Simple Popup Spell Checking

To use RapidSpell Web to spell check a web page in popup mode, create a page holding the

RapidSpellWeb Tag, then add the RapidSpellWebLauncher Tag to your existing page with the text element

you want checked, referencing the page you created with RapidSpellWeb in the rapidSpellWebPage property.

Example, note this code is highly simplistic for demonstration purposes.

Code Example RapidSpellCheckerPopUp.jsp

Page containing the RapidSpellWeb Tag

<%@ taglib uri="http://www.keyoti.com/" prefix="RapidSpellWeb" %>

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">

<html>

<title>Spell Check</title>

<body>

<Center>

<RapidSpellWeb:rapidSpellWeb/>

</center>

</body>

</html>

Code Example RSWL-Simple.jsp

Page containing the RapidSpellWebLauncher Tag, where the text element to be checked is located.

<%@ taglib uri="http://www.keyoti.com/" prefix="RapidSpellWeb" %>

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">

<HTML>

<BODY >

<%

if(request.getParameter("fMessage") == null){

%>

<form action='RSWL-Simple.jsp' method='post' name='myForm' id='myForm'>

<input type='hidden' name='fMessage' value='complete'>

<textarea name="sourceTextBox" wrap='true' cols='40' rows='10'>This

is some sample text with daliberate spelling errars</textarea>

<br>

<!-- Creates a 'Check Spelling' button,

TextComponentName = name of textarea to check,

-->

<RapidSpellWeb:rapidSpellWebLauncher

rapidSpellWebPage="RapidSpellCheckerPopUp.jsp"

textComponentName="myForm.sourceTextBox"

separateHyphenWords="false"

userDictionaryFile="/dictionary.txt"

/>

<input type='submit'>

</form>

<%

} else {

%>

Text entered was:

"<%=request.getParameter("sourceTextBox")%>"

<%

}

%>

</body>

</HTML>

The main page (RSWL-Simple.jsp) uses the RapidSpellWebLauncher Tag to create the check spelling

button, it’s properties specify which form element to check (textComponentName), the URL of the page

containing the RapidSpellWeb control (rapidSpellWebPage) and the mode (mode). Note that (for

mode=’popup’) the properties textComponentName and callBack refer to form elements in Javascript

notation, relative to the document, i.e. they should always have the name of the form (or an element from the

forms array) followed by the text field name. RapidSpellWebPage can be a relative or absolute URL.

User Options

There are several options available to the user via the "Options..." button in the dialog. Any changes to these options will override any settings specified in code. To disable the user options button (and any settings specified by the user), set the EnableOptions property in RapidSpellWebLauncher to false.

User options are stored in browser cookies and are not transferable to other devices as-is.


RapidSpell Web Java Documentation: Setting Style

Setting Style

It is very simple to define the style properties of the HTML elements in the Tags, eg;

Code Snippet Button Customization

ignoreButtonStyle="font-family:'Tahoma,Arial,Helvetica';font-size:10pt;

border:1px solid #b5bed6; background-color:#dddddd; width: 90px;"

ignoreButtonOnMouseOver="this.style.backgroundColor='#b5bed6';this.style.borderColor='#08246b';"

ignoreButtonOnMouseOut="this.style.backgroundColor='#dddddd';this.style.borderColor='#b5bed6';"

This specifies the style using regular CSS syntax and also specifies onMouseOver/Out Javascript

events to modify the style for an attractive effect.


RapidSpell Web Java Documentation: Separate Page Spell Checking

Separate Page Spell Checking

To use RapidSpell Web to spell check a web page in separate mode, create a page holding the

RapidSpellWeb Tag, then add the RapidSpellWebLauncher Tag to your existing page with the text element

you want checked, referencing the page you created with RapidSpellWeb in the RapidSpellWebPage

property.

Code Example From SpellCheckSeparatePage.jsp

Page containing the RapidSpellWeb Tag.

<%@ taglib uri="http://www.keyoti.com/" prefix="RapidSpellWeb" %>

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">

<HTML>

<HEAD>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

<style>.....</style>

</HEAD>

<BODY ...>

<!-- Any HTML formatting can go here -->

<RapidSpellWeb:rapidSpellWeb

ignoreButtonStyle="...."

ignoreButtonOnMouseOver="...."

ignoreButtonOnMouseOut="...."

ignoreAllButtonStyle="...."

ignoreAllButtonOnMouseOver="...."

ignoreAllButtonOnMouseOut="...."

....

..Other button style definitions..

....

/>

</BODY>

</HTML>

Code Example From RSWL-Separate.jsp

Page containing the RapidSpellWebLauncher Tag

<%@ taglib uri="http://www.keyoti.com/" prefix="RapidSpellWeb" %>

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">

<HTML>

<HEAD>

<style>...</style>

</HEAD>

<BODY ...>

<%

if(request.getParameter("fMessage") == null){

%>

<p>This demo page opens the spell checker in a separate page.

<form action='RSWL-Separate.jsp' method='post' name='myForm'>

<input type='hidden' name='fMessage' value='complete'>

<% if(request.getParameter("RSCallBack") == null){ %>

<textarea name="sourceTextBox" wrap='true' cols='40'

rows='10'>This is some sample text with daliberate spelling errars</textarea>

<% } else { %>

<textarea name="sourceTextBox" wrap='true' cols='55'

rows='10'><%= request.getParameter("CorrectedText") %></textarea>

<% } %>

<br>

<!-- Creates a 'Check Spelling' button, TextComponentName = name of

textarea to check, CallBack = name of to put corrected text -->

<RapidSpellWeb:rapidSpellWebLauncher

rapidSpellWebPage="SpellCheckSeparatePage.jsp"

textComponentName="myForm.sourceTextBox"

callBack="RSWL-Separate.jsp"

separateHyphenWords="false"

mode="separate"

buttonStyle="font-family:'Tahoma,Arial'; border:1px solid

#b5bed6; background-color:#dddddd;"

buttonOnMouseOut="this.style.backgroundColor='#dddddd';this.style.borderColor='#b5bed6';"

buttonOnMouseOver="this.style.backgroundColor='#b5bed6';this.style.borderColor='#08246b';"

/>

<input type='submit' Style="font-family:'Tahoma,Arial'; border:1px

solid #b5bed6; background-color:#dddddd;"

onMouseOut="this.style.backgroundColor='#dddddd';this.style.borderColor='#b5bed6';"

onMouseOver="this.style.backgroundColor='#b5bed6';this.style.borderColor='#08246b';"

>

</form>

<%

} else {

%>

Text entered was:

"<%=request.getParameter("sourceTextBox")%>"

<%

}

%>

</BODY>

</HTML>

In these pages the style of the buttons has been set through the properties of the controls. Note that

the callBack is set to the URL of the page the user should be directed to after they have finished checking

the document, this page is called with the parameter CorrectedText which holds the text after the spell

check.


RapidSpell Web Java Documentation: Customising RapidSpellWeb Layout

Customising RapidSpellWeb Layout

It is possible to customise the layout of the spell checker using a HTML template mechanism. This is

done by specifying the layout property with a string of Html using special tags to indicate the position of the

essential spell checker elements. The tags are <PreviewPane/>*, <AddButton/>, <IgnoreButton/>,

<IgnoreAllButton/>, <ChangeButton/>, <ChangeAllButton/>, <FinishButton/>, <UndoButton/>*,

<ChangeToLabel/>, <ChangeToBox/>*,<OptionsButton/>*, <SuggestionsLabel/>, <SuggestionsBox/>* - tags marked with *

are required for correct functionality.

Code Example From CustomSpellCheckerPopUp.jsp With Customized Layout

Page containing the RapidSpellWeb Tag

<%@ taglib uri="http://www.keyoti.com/" prefix="RapidSpellWeb" %>

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">

<html>

<head>

<title>Spell
Check</title>

    <style type="text/css">

body{overflow:hidden;
font-family: sans-serif, arial, helvetica;

}
div{height:100%;}

#rsw_documentTextPanel
{
border: 1px solid #aaa;
border-radius: 3px;
}
#rsw_word, #suggestions
{
border: 1px solid #aaa;
border-top-color: #a0a0a0;
}
#rsw_optionsDialog
{
font-size:.80em;
display: none;
position: absolute;
margin-left: auto;
margin-right: auto;
margin-top: auto;
margin-bottom: auto;
left: 0;
right: 0;
top: 0;
bottom: 0;
width: 295px;
height: 230px;
z-index: 101;
background-color: white;
border: 1px solid #444;
border-radius: 5px;
padding: 8px;
}
#rsw_optionsDialog_Backing
{
display: none;
position: absolute;
margin-left: auto;
margin-right: auto;
margin-top: auto;
margin-bottom: auto;
left: 0;
right: 0;
top: 0;
bottom: 0;
width: 100%;
height: 100%;
background-color: rgba(100,100,100,.60);
z-index: 100;
}
#rsw_optionsDialog > label
{
display: block;
padding-bottom: 12px;

}
#rsw_optionsDialog > input
{
margin-right: 9px;
margin-top:12px;
}
#rsw_optionsHeader
{
font-size: 1.2em;
border-bottom: 1px solid #aaa;
}

</style>
</head>

<body>

<Center>

<RapidSpellWeb:rapidSpellWeb

changeToBoxStyle="font-size:10pt; width:200px; font-family:'arial,

helvetica, sans-serif';"

changeToLabelStyle="font-size:9pt; font-family:'arial, helvetica, sansserif';

"

suggestionsBoxStyle="font-size:10pt; width:200px; font-family:'arial,

helvetica, sans-serif';"

suggestionsLabelStyle="font-size:9pt; font-family:'arial, helvetica, sansserif';"

previewPaneStyle="font-family: 'arial, sans-serif, helvetica'; font-size:

8pt; font-weight:bold;"

previewPaneWidth="200"

previewPaneHeight="190"

ignoreButtonStyle="font-family:'Tahoma,Arial,Helvetica';font-size:10pt;

border:1px solid #b5bed6; background-color:#dddddd; width: 90px;"

ignoreButtonOnMouseOver="this.style.backgroundColor='#b5bed6';this.style.borderColor='#08246b';"

ignoreButtonOnMouseOut="this.style.backgroundColor='#dddddd';this.style.borderColor='#b5bed6';"

.....button styles.....

finishButtonOnMouseOut="this.style.backgroundColor='#dddddd';this.style.borderColor='#b5bed6';"

layout="

<table border=0>

<tr><td colspan=3 bgcolor='#eeeeee'><b>MyCo Spell Checking</b></td></

tr>

<tr><td>

<PreviewPane/>

</td>

<td>

<table border=0 height=190>

<tr><td>

<ChangeToLabel/>

</td></tr><tr><td>

<ChangeToBox/>

</td></tr><tr><td>

<SuggestionsLabel/>

</td></tr><tr><td valign=bottom>

<SuggestionsBox/>

</td></tr>

</table>

</td>

<td>

<table border=0 height=160>

<tr><td>

<IgnoreButton/>

</td></tr><tr><td>

<IgnoreAllButton/>

</td></tr><tr><td>

<AddButton/>

</td></tr><tr><td>

<ChangeButton/>

</td></tr><tr><td>

<ChangeAllButton/>

</td></tr> <tr><td> <OptionsButton/> </td></tr> <tr><td> <tr><td>

<UndoButton/>

</td></tr><tr><td>

<FinishButton/>

</td></tr>

</table>

</td>

</tr>

</table>

"

/>

</center>

</body>

</html>

The only restriction is that the special tags must be on a line by themselves.


RapidSpell Web Java Documentation: Specifying User Dictionaries

User Dictionaries (Add Button)

It is possible to use user dictionaries with RapidSpell Web, on a one user dictionary for all users, or one user dictionary per user or one user dictionary per group basis. The user dictionary file is specified in the userDictionaryFile property of the RapidSpellWebLauncher or RapidSpellWeb (the popup JSP) tag. This property specifies the path to the user dictionary file on the server, the developer has total control over which dictionary file is used for a user. Therefore it is up to the developer to manage a user's session and retrieve the path to a particular user's/group's dictionary file, if required.

The userDictionaryFile property can be set either to an absolute file path (eg. c:\somedir\userdict.txt) or to a URL relative to the application root (eg. ~/dictionaries/userdict.txt which points to a folder named dictionaries under the application's top folder).

Code Example - from RapidSpellWebLauncher

<RapidSpellWeb:rapidSpellWebLauncher

id="rswl"

textComponentName="..."

userDictionaryFile="~/dictionaries/dictionary.txt"

/>

Code Example - from RapidSpellWeb (popup)

<RapidSpellWeb:rapidSpellWeb

userDictionaryFile="~/dictionaries/dictionary.txt"

/>

Setting The Storage Directory Path

As a security measure, when the userDictionaryFile is set in RapidSpellWebLauncher (as opposed to RapidSpellWeb in the popup), RapidSpell locks down user dictionary storage to locations specified in the application's web.xml file, and only allows files of type .txt to be used as user dictionaries.

1. Set a paramter called RapidSpellUserDictionaryDirs in web.xml to a comma delimited list of directories where you intend to store user dictionary files.

eg.

<?xml version="1.0" encoding="UTF-8"?>

<web-app ...>

    <context-param>
        <param-name>RapidSpellUserDictionaryDirs</param-name>
        <param-value>~/dictionaries/</param-value>
    </context-param>

....
</web-app>

This will mean that userDictionaryFile in the tags must be set to a file under ~/dictionaries/.
It may be necessary to restart the app. server after changing the web.xml, for it to have effect.

2. User dictionaries must now be .txt files, so with the above setting a valid userDictionaryFile value is "~/dictionaries/somename.txt"


RapidSpell Web Java Documentation: Using RapidSpell Web With 3rd Party Components

Using RapidSpell Web With 3rd Party Components

3rd Party text components can be used with RapidSpell Web. Html text box support is built in, but

other types of text components can be used if they allow Javascript to access their text. To use with an

Html text box simply set ignoreXML to true (this will mean HTML tags are ignored), set

TextComponentInterface to "HTMLTextBox" and set TextComponentName to the name of the component.

Code Example Extract From RSWL-3rdParty.jsp Using An Html Text Box

Page containing the RapidSpellWebLauncher Tag

.......................

<RapidSpellWeb:rapidSpellWebLauncher

rapidSpellWebPage="RapidSpellCheckerPopUp.jsp"

textComponentName="HTB"

ignoreXML="true"

textComponentInterface="HTMLTextBox"

/>

.......................

To use RapidSpell Web with other 3rd party components it is necessary to write a custom Javascript

interface which will perform two tasks for RapidSpell Web, it must get the text from the control and set text

to the control. To enable the use of a custom interface the TextComponentInterface property should be set

to “Custom”, and a Javascript (ECMAscript) block should be written into the form containing RapidSpell

Web (Launcher). As an example, a custom interface for the standard HTML text area will be built, to

demonstrate the concepts.

Firstly the RapidSpellWebLauncher control’s TextComponentInterface is set to Custom:

<RapidSpellWeb:rapidSpellWebLauncher id="rapidSpellWebLauncher"

textComponentName="myForm.tA"

mode="popup"

textComponentInterface="Custom"

ignoreXML="true"

rapidSpellWebPage="RapidSpellCheckerPopUp.jsp"/>

Next an interface must be written in Javascript, RapidSpell will expect a type RSCustomInterface to

be defined, of the following structure:

function RSCustomInterface(tbElementName){

this.tbName = tbElementName;

this.getText = getText;

this.setText = setText;

function getText(){

//return the text from the text component named

this.tbName,

//this may be HTML formatted text

return .........

}

function setText(text){

//set the text in the text component to the text argument

//this may be HTML formatted text

........

}

}

The two functions, getText and setText must be written to the specifications of the 3rd party component,

note that if they will return XML(HTML) formatted text that the RapidSpellWebLauncher property

ignoreXML should be set to true, otherwise the XML tags will be spell checked. In this example the interface

will be interfacing with a regular HTML <textarea> in which the text contained is accessed using the

format

document.formName.textAreaName.value

getText and setText can then be written as;

function getText(){

return eval('document.'+this.tbName+'.value');

}

function setText(text){

eval('document.'+this.tbName+'.value = text') ;

}

which dynamically accesses the text box named in the this.tbName variable. When RapidSpell runs it

instantiates an object of type RSCustomInterface using the Javascript line

var interfaceObjectName = new RSCustomInterface(_textComponentName);

where _textComponentName is specified by the property TextComponentName in

RapidSpellWebLauncher.

This gives the full code, for a custom interface as;

<%@ taglib uri="http://www.keyoti.com/" prefix="RapidSpellWeb" %>

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">

<HTML>

<HEAD>

<script>

function RSCustomInterface(tbElementName){

this.tbName = tbElementName;

this.getText = getText;

this.setText = setText;

function getText(){

return eval('document.'+this.tbName+'.value');

}

function setText(text){

eval('document.'+this.tbName+'.value = text') ;

}

}

</script>

</HEAD>

<BODY>

<form action='exampleTextBox10-Custom.aspx' method='post' name='myForm'>

<textarea name='tA'></textarea>

<br>

<RapidSpellWeb:rapidSpellWebLauncher id="rapidSpellWebLauncher"

textComponentName="myForm.tA"

mode="popup"

textComponentInterface="Custom"

ignoreXML="true"

rapidSpellWebPage="RapidSpellCheckerPopUp.jsp"/>

</form>

</BODY>

</HTML>


RapidSpell Web Java Documentation: Spell Checking Multiple Text Boxes

Spell Checking Multiple Text Boxes

It is possible to check more than one text box on a Web Form, however with a couple of limitations, it

is not possible to use the ‘separate page’ mode, only pop up may be used and also it is not possible to send

the corrected text to a box other than the one it came from (the callBack property must not be set).

Code Example

Page containing the RapidSpellWebLauncher Tag

<form action='exampleTextBox8-2boxes.jsp' method='post' name='myForm'>

<input type='hidden' name='fMessage' value='complete'>

<textarea name="sourceTextBox" wrap='true' cols='55' rows='10'></

textarea>

<br>

<RapidSpellWeb:rapidSpellWebLauncher

id="rapidSpellWebLauncher1"

rapidSpellWebPage="RapidSpellCheckerPopUp.jsp"

textComponentName="myForm.sourceTextBox"

/>

<textarea name="sourceTextBox2" wrap='true' cols='55' rows='10'></

textarea><br>

<RapidSpellWeb:rapidSpellWebLauncher

id="rapidSpellWebLauncher2"

rapidSpellWebPage="RapidSpellCheckerPopUp.jsp"

textComponentName="myForm.sourceTextBox2"

/>

</form>


RapidSpell Web Java Documentation: Servlet Usage

Servlet Usage

RapidSpell Web provides convenient JavaBeans to enable use with Servlets. The Beans,

RapidSpellWebLauncherBean and RapidSpellWebBean mirror the properties of the Tags described in this

guide, and given the ‘single round trip’ nature of RapidSpell Web make adding spell checking to new and

existing Servlets relatively easy.

Code Example Extract From RSServletUsage.zip Example App

Page containing the RapidSpellWebLauncher.

import javax.servlet.*;

import javax.servlet.http.*;

import java.io.*;

import com.keyoti.rapidSpell.web.*;

/** The servlet which will use the launcher button */

public class SpellUser extends HttpServlet{

/**Process a GET request*/

public void doGet(HttpServletRequest request,

HttpServletResponse response){

processRequest(request, response);

}

/**Process a POST request*/

public void doPost(HttpServletRequest request,

HttpServletResponse response){

processRequest(request, response);

}

/** Generic request processor */

protected void processRequest(HttpServletRequest request,

HttpServletResponse response){

try{

PrintWriter pW = response.getWriter();

pW.println(“<html><body><form name="f1"><textarea name=’n1'

cols=50 rows=5></textarea>”);

//Add RapidSpellWebLauncher to page

RapidSpellWebLauncherBean launcher = new

RapidSpellWebLauncherBean();

launcher.setTextComponentName("f1.n1");

launcher.setRapidSpellWebPage("/rsuser/RSWebPopUp");

launcher.writeHtml(pW, request);

pW.println("</form></body></html>");

} catch (IOException e){

//.................

}

}

}

Page containing RapidSpellWeb.

import javax.servlet.*;

import javax.servlet.http.*;

import java.io.*;

import com.keyoti.rapidSpell.web.*;

/** Note that if the user dictionary is being used this servlet will receive GET

requests aswell as the usual POST requests. */

public class RSWebPopUp extends HttpServlet{

public void doGet(HttpServletRequest request,

HttpServletResponse response){

processRequest(request, response);

}

public void doPost(HttpServletRequest request,

HttpServletResponse response){

processRequest(request, response);

}

protected void processRequest(HttpServletRequest request,

HttpServletResponse response){

try{

PrintWriter pW = response.getWriter();

pW.println("<html><body><center>");

//Add RapidSpellWeb to page

RapidSpellWebBean checker = new RapidSpellWebBean();

checker.writeHtml(pW, request);

pW.println("</center></body></html>");

} catch (IOException e){

//...........

}

}

}

Please consult the Servlet zip file for a demonstration application. The same principle applies to the

RapidSpellWInlineBean.


RapidSpell Web Java Documentation: Spell Checking Multiple Text Boxes With One Button

Spell Checking Multiple Text Boxes With One Button

It is possible to check more than one text box on a page with one button, using the

RapidSpellWebMultiple Tag (or RapidSpellWebMultipleBean).

Code Example Extract From RSWL-MultipleBoxes.jsp

Page containing the RapidSpellWebMultiple.

<%@ taglib uri="http://www.keyoti.com/" prefix="RapidSpellWeb" %>

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">

<HTML>

<BODY >

<form action='exampleTextBox1.jsp' method='post' name='myForm'>

<!--------------------- Text box 1 -------------------->

<textarea name="sourceTextBox" wrap='true' cols='55'

rows='10'>This is boxx 1.</textarea>

<br><br>

<RapidSpellWeb:rapidSpellWebLauncher

id="rapidSpellWebLauncher"

rapidSpellWebPage="RapidSpellCheckerPopUp.jsp"

textComponentName="myForm.sourceTextBox"

RSMultipleID="RapidSpellWebMultiple1"

/>

<br><br>

<!--------------------- Text box 2 ------------------->

<textarea name="sourceTextBox2" wrap='true' cols='55'

rows='10'>This is boxx 2.</textarea>

<br><br>

<RapidSpellWeb:rapidSpellWebLauncher

id="rapidSpellWebLauncher2"

rapidSpellWebPage="RapidSpellCheckerPopUp.jsp"

textComponentName="myForm.sourceTextBox2"

RSMultipleID="RapidSpellWebMultiple1"

/>

<br><Br>

<!--------------------- Text box 3 ------------------->

<textarea name="sourceTextBox3" wrap='true' cols='55'

rows='10'>This is boxnumber 3.</textarea>

<br><br>

<RapidSpellWeb:rapidSpellWebLauncher

id="rapidSpellWebLauncher3"

rapidSpellWebPage="RapidSpellCheckerPopUp.jsp"

textComponentName="myForm.sourceTextBox3"

RSMultipleID="RapidSpellWebMultiple1”

/>

<RapidSpellWeb:rapidSpellWebMultiple id="RapidSpellWebMultiple1" tabIndex="1"

rapidSpellWebLaunchers="rapidSpellWebLauncher,rapidSpellWebLauncher2,rapidSpellWebLauncher3"/

>

</form>

<p><font face='arial, helvetica'><a href="index.html">Back to

contents page.</a></font>

</BODY>

</HTML>

Notice that the RapidSpellWebMultiple Tag refers to all the RapidSpellWebLaunchers that it should

start in the course of the spell check. Also, each RapidSpellWebLauncher refers back to the

RapidSpellWebMultiple Tag. All controls must have the “id” attribute set, in order for this to work. If a

RapidSpellWebLauncher is not correctly referenced, it will still appear on the form as button, otherwise it

will be hidden.


RapidSpell Web Java Documentation: SSL Site Usage

SSL Site Usage

RapidSpell Web is compatible with SSL web-sites. To use the components over SSL the SSLFriendly

attribute must be set to true in the RapidSpellWeb and RapidSpellWebLauncher Tags/Beans, and a file

named “blank.html” must be present in the same folder as the page where RapidSpellWeb and

RapidSpellWebLauncher are used. The purpose of “blank.html” is to give the browser something to load in

the Iframes using SSL. If this doesn’t happen then a ‘mixed content’ warning will appear.; “blank.html”

should be a bare bones html page.

Code Example SSL Usage

Page containing the RapidSpellWeb control.

<%@ taglib uri="http://www.keyoti.com/" prefix="RapidSpellWeb" %>

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">

<html><body><Center>

<RapidSpellWeb:rapidSpellWeb SSLFriendly="true"/>

</center></body></html>

Blank.html

<html><body></body></html>


RapidSpell Web Java Documentation: Modal Dialog Usage

Modal Dialog Usage

When RapidSpell Web is used in popup mode the popup is by default non modal (user focus can

go anywhere). To make the popup modal (user focus is limited to the spell checker) set the “modal”

attribute in RapidSpellWebLauncher to true and copy RapidSpellModalHelper.html from the

distribution demo folder to the folder where RapidSpellWebLauncher is used.


RapidSpell Web Java Documentation: Basic Static Inline

Basic Static Inline

When RapidSpellWInline is working with a plain textarea or input field, it works in ‘static’ mode. This

means that underlines are shown as an overlay over the text box. This is the most compatible mode of

operation and works with all modern browsers (Internet Explorer 5+, Netscape 6+, Firefox 1, Opera, and

Safari on the PC and Mac). To work with a textbox the textComponentID attribute in RapidSpellWInline

must be set to that of the text box.

Code Example From RSWI-Static.jsp

<textarea id="tb1" cols="30" rows="5" style="font-family: Verdana,

Sans-Serif; font-size:11pt;">A regular plain textarea!</textarea>

<RapidSpellWeb:rapidSpellWInline

textComponentID="tb1"

id="rswi1"

/>


RapidSpell Web Java Documentation: Dynamic And As You Type Inline

Dynamic And As You Type Inline

To enable ‘dynamic’ (which means that the text will be editable AND underlined) checking, a

RapidSpellWInlineTextBox must be used. To go further and enable ‘as you type’ checking, just set

checkAsYouType="true" in RapidSpellWInline.

Code Example From RSWI-AsYouType.jsp

<form>

<RapidSpellWeb:rapidSpellWInlineTextBox id="rswitb1"

width="300" height="300"

>I'm as yuu typed</RapidSpellWeb:rapidSpellWInlineTextBox>

<RapidSpellWeb:rapidSpellWInline

id="rswi1"

textComponentID="rswitb1"

checkAsYouType="true"

showButton="false"

/>

</form>

Code Example Setting Style From RSWI-DynamicWithStyle.jsp

<RapidSpellWeb:rapidSpellWInlineTextBox id="rswitb1"

width="300" height="300"

styleFontFamily="Batang, Garamond, Serif"

styleFontSize="14pt"

styleBackColor="#ccffff"

styleBorderStyle="dotted"

styleBorderWidth="1"

styleBorderColor="black"

>This shows some of the style settings available with the dynamic

text box, and non as you type mode.</RapidSpellWeb:rapidSpellWInlineTextBox>

<RapidSpellWeb:rapidSpellWInline

id="rswi1"

textComponentID="rswitb1"

showButton="true"


RapidSpell Web Java Documentation: User Dictionaries (Add Option)

User Dictionaries (Add Option)

To activate the 'Add' option specify the userDictionaryFile attribute to a valid text file path on the server.

The userDictionaryFile property can be set either to an absolute file path (eg. c:\somedir\userdict.txt) or to a URL relative to the application root (eg. ~/dictionaries/userdict.txt which points to a folder named dictionaries under the application's top folder).

Code Example

<RapidSpellWeb:rapidSpellWInline

id="rswi"

textComponentID="..."

userDictionaryFile="~/dictionaries/dictionary.txt"

/>

Setting The Storage Directory Path

As a security measure, RapidSpell locks down user dictionary storage to locations specified in the application's web.xml file, and only allows files of type .txt to be used as user dictionaries.

1. Set a paramter called RapidSpellUserDictionaryDirs in web.xml to a comma delimited list of directories where you intend to store user dictionary files.

eg.

<?xml version="1.0" encoding="UTF-8"?>

<web-app ...>

    <context-param>
        <param-name>RapidSpellUserDictionaryDirs</param-name>
        <param-value>~/dictionaries/</param-value>
    </context-param>

....
</web-app>

This will mean that userDictionaryFile in the tags must be set to a file under ~/dictionaries/.
It may be necessary to restart the app. server after changing the web.xml, for it to have effect.

2. User dictionaries must now be .txt files, so with the above setting a valid userDictionaryFile value is "~/dictionaries/somename.txt"


RapidSpell Web Java Documentation: Multiple Textboxes

Multiple Textboxes

Regardless of whether using a plain (static) or dynamic textbox, setting up multiple RapidSpellWInline

tags to work with one button simply requires the use of the RapidSpellWebMultiple tag. To do this, add

RapidSpellWebMultiple to the page and give it an “id” attribute. Then set the rsMultipleID attribute in each

RapidSpellWInline to the id of the multiple tag. Lastly, set rapidSpellWebLaunchers to a list of ids to

launch.

Note; if activating As You Type, do not use RapidSpellWebMultiple as it is unnecessary and will

confuse the behavior.

Code Example From RSWI-MultipleBoxes.jsp

<textarea id="ta" name="ta" rows=14 cols=30 >In thispage we

demenstrate</textarea>

<RapidSpellWeb:rapidSpellWInline

id="rswi"

textComponentID="ta"

rsMultipleID="rswm"

/>

<textarea id="ta2" name="ta2" rows=14 cols=30 >multiple textboxes being

checked</textarea>

<RapidSpellWeb:rapidSpellWInline

id="rswi2"

textComponentID="ta2" rsMultipleID="rswm"

/>

<textarea id="ta3" name="ta3" rows=14 cols=30 >with one button.

Note that RapidSpellWInlineTextBox could have been used in place of

&lt;textarea&gt;</textarea>

<RapidSpellWeb:rapidSpellWInline

id="rswi3"

textComponentID="ta3" rsMultipleID="rswm"

/>

<RapidSpellWeb:rapidSpellWebMultiple

rapidSpellWebLaunchers="rswi,rswi2,rswi3" id="rswm"

showFinishedMessage="false" />


RapidSpell Web Java Documentation: 3rd Party Textboxes

3rd Party Textboxes

RapidSpellWInline automatically identifies editable elements and therefore can work with most 3rd

party components very simply. When the Automatic interface is unable to work with an editor, writing a

Custom interface (as with RapidSpellWebLauncher) is an alternative option.

In this example, the IFRAME “HTB” is made editable and images are used in place of the button.

Code Example From RSWI-3rdParty.jsp

<RapidSpellWeb:rapidSpellWInline id="rswi"

textComponentID="HTB"

ignoreXML="true"

buttonImageMouseOut="images/out1.png"

buttonImageMouseOver="images/over1.png"

buttonImageMouseDown="images/down1.png" />

<iframe id="HTB" width="400" height="300"></iframe>


RapidSpell Web Java Documentation: Using With Struts

Using With Struts

RapidSpellWInline can only work with textboxes that have the “id” attribute set in HTML. To have

Struts output an “id” attribute, the “styleId” attribute must be set to some value in the JSP tag.

Eg.

<html:textarea property="title" styleId="tb12"/>

<RapidSpellWeb:rapidSpellWInline id="rswi1" textComponentID="tb12"/>

This works well, but when attempting to use with an Iterator tag, a runtime expression is needed to set

the styleId, see below.

Code Example With Iterator

<%

int i=0;

String launchers = "";

%>

<logic:iterate id="myCollectionElement" name="list2">

<bean:write name="myCollectionElement" /><br />

<%

i++;

String id="tb"+i;

String rswiID="r"+id;

launchers +=rswiID+",";

%>

Field: <html:textarea property="title" indexed="true"

styleId="<%=id%>"/>

<br />

<br />

<RapidSpellWeb:rapidSpellWInline

id="<%=rswiID%>"

textComponentID="<%=id%>"

rsMultipleID="rswm"

/>

</logic:iterate>

<%//pull off trailing comma

launchers=launchers.substring(0, launchers.length()-1);

%>

<RapidSpellWeb:rapidSpellWebMultiple id="rswm"

rapidSpellWebLaunchers="<%=launchers%>"

showFinishedMessage="false"

/>


RapidSpell Web Java Documentation: Using With JSF

Using With JSF

Use with JSF is mostly the same as with JSP tags, however care must be taken when setting the

textComponentID attribute;

With RapidSpellWInlineTextBox - set textComponentID to the “id” of the text box

With regular text areas - set textComponentID to the “id” of the text box as rendered in HTML

(typically “formID:textBoxID”)

Code Example With RapidSpellWInlineTextBox

<?xml version="1.0" encoding="UTF-8"?>

<jsp:root version="2.1" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html"

xmlns:jsp="http://java.sun.com/JSP/Page" xmlns:webuijsf="http://www.sun.com/webui/webuijsf"

xmlns:ors="http://www.keyoti.com/"

>

<jsp:directive.page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"/>

<f:view>

<webuijsf:page binding="#{Page1.page1}" id="page1">

<webuijsf:html binding="#{Page1.html1}" id="html1">

<webuijsf:head binding="#{Page1.head1}" id="head1">

<webuijsf:link binding="#{Page1.link1}" id="link1" url="/resources/stylesheet.css"/>

</webuijsf:head>

<webuijsf:body binding="#{Page1.body1}" id="body1" style="-rave-layout: grid">

<webuijsf:form binding="#{Page1.form1}" id="form1">

<ors:rapidSpellWInlineTextBox id="rswitb" width="300" height="300"/>

<ors:rapidSpellWInline id="rswi" textComponentID="rswitb"/>

</webuijsf:form>

</webuijsf:body>

</webuijsf:html>

</webuijsf:page>

</f:view>

</jsp:root>

Code Example With Standard TextBox

(as above example, except with this change)

<webuijsf:form binding="#{Page1.form1}" id="form1">

<h:inputTextarea id="ta"/>

<ors:rapidSpellWInline id="rswi" textComponentID="form1:ta"/>

</webuijsf:form>


RapidSpell Web Java Documentation: Non-GUI Spell Checker

Non-GUI Spell Checker

The RapidSpellChecker Bean component is of particular use in non-GUI scenarios such as the

web. Below is a very simple excerpt of how this component can be used.

Code Example

.........

RapidSpellChecker c = new RapidSpellChecker();

BadWord badWord;

Enumeration suggestions;

//check some text.

c.check(“This is sume text.”);

//iterate through all bad words in the text.

while((badWord = c.nextBadWord())!=null){

System.out.println(badWord.getWord() + “- is not spelt correctly.

Suggestions:”);

try{

//get suggestions for the current bad word.

suggestions = c.findSuggestions().elements();

//display all suggestions.

while(suggestions.hasMoreElements()) {

System.out.println(suggestions.nextElement());

}

//change the bad word in the text with “replacement”.

c.changeBadWord(“replacement”);

} catch (NoCurrentBadWordException e){

System.err.println(e);

}

}

System.out.println(c.getAmendedText());

.........


RapidSpell Web Java Documentation: License Keys In Multi Server Development Environments

License Keys In Multi Server Development Environments

It is common practice to use multiple servers in the development of web applications, for example, an

application may go through a lifecycle;

developer machines (“localhost”) -> single development test server (“devServer”) -> QA server

(“qaServer”) -> production server (“prodServer”)

The current licensing system requires keys for “devServer”, “qaServer” and “prodServer” if they are

accessed through non local browsers (note; ‘devServer’ and ‘qaServer’ keys will be provided free), this

poses a problem since it is usually unacceptable to change the “licenseKey” attribute in the tag source code

for each server.

Since each server has it’s own environmental settings, it is likely that a config file is being used already,

if the config file is unique to each server, then the RapidSpellWeb license key for each server can also be

stored there. Once this is done it is easy to set the licenseKey attribute at runtime

Eg for RapidSpellWeb tag (same applies for RapidSpellWInlineHelper);

<%@ taglib uri="http://www.keyoti.com/" prefix="RapidSpellWeb" %>

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">

<html>

<title>Spell Check</title>

<body>

<Center>

<%

String licenseKey = ....//Obtain license key from config file

%>

<RapidSpellWeb:rapidSpellWeb licenseKey="<%= licenseKey %>"/>

</center>

</body>

</html>


RapidSpell Web Java Documentation: Suggestions Algorithm

Suggestions Algorithm

It is possible to choose the algorithm used to find suggestions for spelling errors, there are two algorithms

on offer, ‘hashing’ (default) and ‘phonetic’. Each algorithm has it’s own advantages and disadvantages;

Hashing (default): Very fast, roughly 40 times faster than the phonetic algorithm, works best on typographic

errors and common spelling mistakes. Similar to most spell checker suggestions.

Phonetic (Sounds like, English only): Slower, works well with genuine attempts to spell correctly, works

poorly with typographic errors. Can appear to produce wild results, although results do sound like the

word in question. Does not work with non English languages. Uncommon.

It is recommended that you choose the suggestions algorithm in line with your target audience. The

phonetic algorithm, although appearing worse overall, is more suited for people who have not spoken

English for very long, e.g. non native English speakers and children.


RapidSpell Web Java Documentation: Consideration Range

Consideration Range

The hashing suggestion algorithm is very fast because it accurately cuts down the list of words to look

at as possible suggestions. The factory default consideration range is 80, which provides optimal speed with

a loss of only a fraction of possible suggestions. It is possible to set the consideration range through the

RapidSpellWebLauncher control and RapidSpellChecker class. The relationship between speed, number

of suggestions and consideration range is shown below.


RapidSpell Web Java Documentation: Client Side Events

Client Side Events

It is possible to determine when spell checking has finished (in pop up mode) by using the

FinishedListener property of RapidSpellWebLauncher. This property can be set to the name of a

JavaScript (ECMAscript) function in the main form, which will be called from the pop up when the user

finishes checking the document (either by completing the check, or by clicking the ‘Finish’ button). The

function must not expect arguments and be with in the scope of the whole page.

For example;

...............

<script>

function notifyDone(){

alert('Finished event captured.');

}

</script>

...............

<RapidSpellWeb:rapidSpellWebLauncher

rapidSpellWebPage="RapidSpellCheckerPopUp.jsp"

textComponentName="myForm.sourceTextBox"

finishedListener="notifyDone"

/>

...............

This example is suited to web pages with single text boxes, for an example that works with multiple

text boxes, please see the file “exampleTextBox11-MultipleCloseEvent.jsp”.


RapidSpell Web Java Documentation: Conclusion

Conclusion

Thank you for using the RapidSpell Web component, we hope that you experience much success with

it. Keyoti is committed to improving all of it’s products and truly values customer feedback of any kind. If

you would like to contact us about any of our products please do so through our web site.

http://www.keyoti.com/contact.html

We thrive on suggestions for components, if you have a component wish please don’t hesitate to get in

touch, it may be the next thing we develop!


RapidSpell Web Java Documentation: Dialog Validator

Dialog Validator

Using the dialog spell checker as a client-side validator.

  1. Setup dialog checking per this topic.
  2. Drag RapidSpell-AYT.js from Solution Explorer into the page, this will add a <script src="RapidSpell-AYT.js"></script> tag to the page with the correct path.
  3. Add the validation function to a Javascript block.
    rapidSpell.ayt_aytEnabled = false;//disable inline checking
rapidSpell.ayt_staticMode = true; //disable inline checking
function validateSpelling(oSrc, args) {
    //Check if spell check already ran.
    for (var i = 0; i < rsw_rapidSpellControls.length; i++) {
        if (rsTCInt[rsw_rapidSpellControls[i]].tbName == oSrc.controltovalidate && rsTCInt[rsw_rapidSpellControls[i]].hasRun) {
            args.IsValid = true;
            return;
        }
    }

    //we import RapidSpell-AYT.js to be able to use RapidSpellCheckerClient
    var rapidSpellChecker = new RapidSpellCheckerClient(rapidSpell.ayt_helperURL);
    rapidSpellChecker.config = rsw_getConfigurationObject('default');
    var result = rapidSpellChecker.Check(args.Value);
    args.IsValid = result.numberOfErrors == 0;
}

    This will check if spell checking has been performed on the text box that is validating, and if not will check it for errors using the RapidSpellCheckerClient class.
  4. Add an asp:CustomValidator to the page for each text box.
    <asp:CustomValidator id="CustomValidator1"  runat="server" ControlToValidate="TextBox1" EnableClientScript='true'
             ErrorMessage="There are spelling errors and spell check hasn't been performed."
             ClientValidationFunction="validateSpelling">
            </asp:CustomValidator>
  5. Tip: it appears that the Java CustomValidator, when using a ClientValidationFunction, does not work in strict page mode (i.e.<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">) - do conduct your own tests.


RapidSpell Web Java Documentation: Inline Validator

Inline Validator

In non-as-you-type spell checking scenarios it may be desirable to have the inline spell checker work as a validator. This can be configured with asp:CustomValidator as a client script validator.

Static mode validation

  1. Setup static mode checking per this topic.
  2. Add the validation function to a Javascript block.
    function validateSpelling(oSrc, args) {
    //Check if spell check already ran.
    for (var i = 0; i < rsw_scs.length; i++) {
        if (rsw_scs[i].textBoxID == oSrc.controltovalidate && rsw_scs[i].hasRun) {
            args.IsValid = true;
            return;
        }
    }

    var rapidSpellChecker = new RapidSpellCheckerClient(rapidSpell.ayt_helperURL);
    rapidSpellChecker.config = rsw_getConfigurationObject('default');
    var result = rapidSpellChecker.Check(args.Value);
    args.IsValid = result.numberOfErrors == 0;
}

    This will check if spell checking has been performed on the text box that is validating, and if not will check it for errors using the RapidSpellCheckerClient class.
  3. Add an asp:CustomValidator to the page for each text box.
    <asp:CustomValidator id="CustomValidator1"  runat="server" ControlToValidate="TextBox1" EnableClientScript='true'
             ErrorMessage="There are spelling errors and spell check hasn't been performed."
             ClientValidationFunction="validateSpelling">
            </asp:CustomValidator>
  4. Tip: it appears that the Java CustomValidator, when using a ClientValidationFunction, does not work in strict page mode (i.e.<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">) - do conduct your own tests.