How to install Spell Checker in TinyMCE when using JSP
I spent a good (read: probably too much) amount of time getting the spellchecker in TinyMCE to work on my Tomcat (JSP) application. The problem with this plugin is that it’s source code runs on PHP - which Tomcat can’t interpret on it’s own.
Instead, I happen to have another web server daemon (lighttpd/php) running on port 81 already to support a phpMyAdmin installation. Unfortunately, I had previously compiled PHP without XML support, so this involved some hacking.
1) Download & compile libxml2, libtool, aspell and pspell (+ English language pack) libraries & dependencies (Not easy to find all compatible for RHEL3). This involves installing via any of the following methods: up2date, rpm –install, or plain old ./configure, make, make install commands. I found the DAG repositries to be a big help.
2) Recompile PHP to support spell checking and xml: ./configure --enable-fastcgi --enable-force-cgi-redirect --with-mysql=/usr/lib --without-pear --with-pspell And then do your make/make install. You’ll notice that fastcgi and cgi-redirect flags are set for lighttpd.
3) Delete any old php sockets:rm -f /tmp/php-fastcgi.socket*
4) Make sure lighttpd has FastCGI enabled in my lighttpd.conf:
fastcgi.server = ( “.php” =>
( “localhost” =>
(
“socket” => “/tmp/php-fastcgi.socket”,
“bin-path” => “/usr/local/bin/php”
)
)
)
5) Restart lighttpd: lighttpd -f lighttpd.conf
6) Take PHP files from TinyMCE spell checker and install in lighttpd’s www directory under /tinymcespellchecker. (these are /classes/*, config.php and tinyspell.php)
7) Edit config.php to use pspell (pick the “command line spell” require_once function, comment out the other 2 kinds)
8) Install httpProxyServlet JAR files in JSP application in /WEB-INF/lib. We need this proxy because spell checker uses AJAX calls to PHP, and since it is located on another server, we have to proxy requests otherwise our browsers won’t let us. More information on this problem from Yahoo’s AJAX proxy HOW-TO.
9) Add lines to your web.xml:
<servlet>
<servlet-name>HttpProxy</servlet-name>
<servlet-class>com.jsos.httpproxy.HttpProxyServlet</servlet-class>
<init-param>
<param-name>host</param-name>
<param-value>http://localhost:81/tinymcespellchecker/tinyspell.php</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>HttpProxy</servlet-name>
<url-pattern>/SpellerProxy</url-pattern>
</servlet-mapping>
<mime-mapping>
<extension>html</extension>
<mime-type>text/html</mime-type>
</mime-mapping>
<mime-mapping>
<extension>txt</extension>
<mime-type>text/plain</mime-type>
</mime-mapping>
10) On my JSP application, install javascripts for TinyMCE spell checker plugin (these are all the files except for the ones mentioned in step 6 at /tinymce/jscripts/tiny_mce/plugins/spellchecker
11) Edit editor_plugin.js to use the new proxy instead of local PHP files:
Add near the top:
var TinyMCE_spellProxy = “http://localhost/myJSPapplication/SpellerProxy”;
Change the 2 instances of self._sendAjax calls to:
self._sendAjax(TinyMCE_spellProxy, self._ajaxResponse, ‘post’, args);
12) Install spell checker plugin in your TinyMCE configuration:
plugins : “spellchecker”,
theme_advanced_buttons1 : “spellchecker,bold,italic…”,
That’s it! Pretty roundabout way to get simple spell checking working.
This post is filed under Computer Science. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.