mahendra kawde
mahendra kawde

Reputation: 847

Integrate CKEditor in JSP

I am using CKEditor in my website. Earlier there was FCKeditor. But it was not compatible with Google Chrome and hence I decided to go with CKEditor. Below screen shot shows how I am using it:

enter image description here

Here there are 2 select box:

  1. select verse
  2. select format

In verse options when I click on New button it opens a page with editor as below:

enter image description here

Here I can type in text and click on Save button it gets added to the select verse dropdown. This is how I can add new verse. So far no issue. Next when I select any option from dropdown(select verse) and click on Edit button it should open the editor with already added text inside it. But it is showing the text outside editor. enter image description here

I am integrating CKEditor with JSP.

My JSP Code:

<%@ taglib uri="http://ckeditor.com" prefix="ckeditor" %>
<ckeditor:editor editor="textValue" basePath="ckeditor/">
        <%=textDesc%>
</ckeditor:editor>

Please help.

Thanks in advance.

Upvotes: 0

Views: 3103

Answers (2)

prakash tyata
prakash tyata

Reputation: 39

<script type="text/javascript"
    src="<c:url value='https://cdn.ckeditor.com/4.7.0/standard/ckeditor.js'/>"></script>

<script type="text/javascript">
                                    CKEDITOR
                                            .replace(
                                                    'ckeditor',
                                                    {
                                                        filebrowserBrowseUrl : '<s:url value="/forckeditor" />'
                                                    //uiColor : '#9AB8F3'
                                                    });
                                </script>

Upvotes: 1

j.swiderski
j.swiderski

Reputation: 2445

First of all, you might want to give a try to new version: https://github.com/ckeditor/ckeditor-java-core, https://github.com/ckeditor/ckeditor-java-samples. It is still under development but what is missing is mainly documentation (the code works). I recommend this version because it uses CKEditor 4.x which is compatible with e.g. IE11.

About your issue - I think there is a problem in a way how you load data into CKEditor. The editor:editor tag (which is in fact "insert editor tag") has value attribute which you should use to pass data into editor. These tags do not accept bodies. I'm not sure why in TLD for version 3.x body-content is set to JSP however it has benn fixed in CKEditor for Java 4.x and body content is now set correctly to empty value.

Please also see the CKEditor for Java 4 equivalent for this tag https://github.com/ckeditor/ckeditor-java-samples/blob/master/src/main/webapp/samples/insertTag.jsp and keep in mind that you don't need to stick to JSP expressions and you may use EL (which is preferred over discouraged expressions, scriptlets etc.).

Upvotes: 0

Related Questions