blog rss feed

Simple use of the FCKeditor in a Grails site.

Author: Dave Cherry last modified
Keywords: groovy grails web

[Updated 3/Sep/2008] There is now a working plugin for fckeditor in Grails, unless you have very specific requirements, please see my more recent blog discussing the new fckeditor plugin for Grails, or alternatively go directly to the new grails fckeditor plugin site.

If like my requirement, you actually only need to edit the text as rich text, and not deal with downloads, then this blog will get you up and running with the editor standalone in the short term.

Downloading and installing FCKeditor into Grails

Download the editor package from http://www.fckeditor.net/download

Now expand the editor zip file into your grails application under the web-app folder. This will create a directory called fckeditor underneath web-app.

In the GSP page where you need the editor, in the <head> section add:

    <script type="text/javascript" src="${createLinkTo(dir:’fckeditor’, file:’fckeditor.js’)}"></script>
 

Then where you wish the rich text control to appear add the following script; in the example below we assume that you are going to present the value of a domainObject property (propertyName) in the editor. On posting the form, the text will be posted in the parameters as ’propertyName’:

    <script type="text/javascript">
        var oFCKeditor = new FCKeditor( ’propertyName’ ) ;
        oFCKeditor.BasePath    = ’${createLinkTo(dir:’fckeditor’)}/’;
        oFCKeditor.Height    = 500 ;

        oFCKeditor.Value    = ’${myDomainObj?.propertyName}’;
        oFCKeditor.Create() ;
    </script>

 

Please leave a comment



Search

Blog calendar

blog: previous month September 2010 blog: next month
su mo tu we th fr sa
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30