Knowledgebase Home Page  >  RapidSpell Web Java
Search the Knowledge Base
How can I customize the way the user dictionary works, or is loaded? How can I load the user dictionary from a database?
https://keyoti.com/kb/Default.aspx?ToDo=view&questId=33&catId=45

Options

Print this page
Email this to a friend

To implement a database based user dictionary, or some othercustom user dictionary implementation, you are free to subclass thecom.keyoti.rapidSpell.UserDictionary class https://keyoti.com/products/rapidspell/javaweb/api/com/keyoti/rapidSpell/UserDictionary.html
 
Then in your inherited class you can override our methods to make it behave howyou wish, eg load the dictionary from your own source, or a database. Here isan empty implementation -
 

 class CUserDictionary extendscom.keyoti.rapidSpell.UserDictionary
 {
  java.util.ArrayList wordList;
  boolean valid = true;

  public CUserDictionary(){
  }

  /** Tries to add <code>word</code> to thisdictionary
  * @param word String containing the new word
  * @return true if added successfully, false otherwise.
  */
  public boolean addWord(String word){
  return true;
  }
 
  /** Read the dictionary word list into <code>list</code>
  * @param list the String arraylist that the word list will be read into.
  * @return number of words in list.
  */
  public int readAll(java.util.ArrayList list){
  return 0;
  }
  /** Returns if the dictionary file is valid. */
  public boolean isValid(){
  return valid;
  }

 }
 
This class should then be set through the setUserDictionary(UserDictionary d)method in RapidSpellChecker
https://keyoti.com/products/rapidspell/javaweb/api/com/keyoti/rapidSpell/RapidSpellChecker.html#setUserDictionary(com.keyoti.rapidSpell.UserDictionary).
 
 
The RapidSpellChecker object is accessible through the UI components in thefollowing ways;

 

Using The CUserDictionary Class

 

If you are using the Javascript approach in version 4 up:

For Inline/As-you-type: 

A. Create a page called rswihelper.jsp with this content

<%@ page contentType="text/html; charset=UTF-8"pageEncoding="UTF-8" %>
<%@ taglib uri="
http://www.keyoti.com/"prefix="RapidSpellWeb" %>
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<title>Spell Check</title>

<%
com.keyoti.rapidSpell.RapidSpellChecker rapidSpellChecker = newcom.keyoti.rapidSpell.RapidSpellChecker(licenseKey);
rapidSpellChecker.setUserDictionary(new CUserDictionary());

%>
<body>
<center>
    <RapidSpellWeb:rapidSpellWInlineHelpercheckerEngine="<%=rapidSpellChecker%>"
/>

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

B. To use the newly created page, call (in the pages using thespell checker)

<script type='text/javascript'>

rapidSpell.ayt_helperURL ="<path to>/rswihelper.jsp";

</script>

 

 

For Dialog:  

A. Create a page called popup.jsp with this content

<%@ taglib uri="http://www.keyoti.com/" prefix="RapidSpellWeb" %>
 
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
 
<html>
 
<title>Spell Check</title>
 
<body>
 
<center>

<%
com.keyoti.rapidSpell.RapidSpellChecker rapidSpellChecker = newcom.keyoti.rapidSpell.RapidSpellChecker(licenseKey);
rapidSpellChecker.setUserDictionary(new CUserDictionary());

%>
<RapidSpellWeb:rapidSpellWeb licenseKey="<your license key here>" 
checkerEngine="<%= rapidSpellChecker %>"/>
/>
 
</center>
 
</body>
 
</html>


 
B. To use the newly created page, call (in the pages using the spell checker)

<script type='text/javascript'>
rapidSpell.dialog_popupURL ="<path to>/popup.jsp";
</script>

 

If you are using the JSP Tag approach (all versions):


For Inline/As-you-type: 

 

A. Create a page called rswihelper.jsp with this content

<%@ page contentType="text/html; charset=UTF-8"pageEncoding="UTF-8" %>
<%@ taglib uri="
http://www.keyoti.com/"prefix="RapidSpellWeb" %>
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<title>Spell Check</title>

<%
com.keyoti.rapidSpell.RapidSpellChecker rapidSpellChecker = newcom.keyoti.rapidSpell.RapidSpellChecker(licenseKey);
rapidSpellChecker.setUserDictionary(new CUserDictionary());

%>
<body>
<center>
    <RapidSpellWeb:rapidSpellWInlineHelper licenseKey
="<your license key here>"

       checkerEngine="<%=rapidSpellChecker%>"
/>

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


B. In your RapidSpellWeb:rapidSpellWInline tags add this attribute

rapidSpellWInlineHelperPage="rswihelper.jsp"


This will make the ajax call use the new JSP page and therefore your customuser dictionary class.

For Dialog:  

A. Create a page called popup.jsp with this content

<%@ taglib uri="http://www.keyoti.com/" prefix="RapidSpellWeb" %>
 
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
 
<html>
 
<title>Spell Check</title>
 
<body>
 
<center>

<%
com.keyoti.rapidSpell.RapidSpellChecker rapidSpellChecker = newcom.keyoti.rapidSpell.RapidSpellChecker(licenseKey);
rapidSpellChecker.setUserDictionary(new CUserDictionary());

%>
<RapidSpellWeb:rapidSpellWeb licenseKey="<your license key here>" 
checkerEngine="<%= rapidSpellChecker %>"/>
/>
 
</center>
 
</body>
 
</html>


 
B. To use the newly created page, in the RapidSpellWebLauncher tag, set theattribute

RapidSpellWebPage="<pathto>/popup.jsp"

 


Related Questions:

Attachments:

No attachments were found.