Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using CKEditor instead of PrimeFaces Editor

I am trying to use CKEditor in my JSF application. How to get the content of CKEditor into backing bean..?

index.xhtml

<form action=""  method="post">
            <p>
            My Editor:<br />
                <textarea cols="90" rows="20"  id="editor1" name="editor1" value="#{EditorBean.value}"></textarea>
                <script type="text/javascript">
                        CKEDITOR.replace( 'editor1',
                        {
                            uiColor: '#85B5D9'
                        });
                </script>
                <input type="button" value="Clear" name="clear" onclick="clear1()"/>
            </p>
        </form>

BackingBean

@ManagedBean public class EditorBean {

private String value;

public String getValue() {
    return value;
}

public void setValue(String value) {
    this.value = value;
    System.out.println("Content: "+value);
}

}

When I tried to print the value, It is not printing. Help me on this issue. PrimeFaces Editor is not supporting "Insert Table" function. So, I want to use CKE.

like image 516
neni Avatar asked May 13 '11 07:05

neni


2 Answers

As el wont be able to evaluate non-JSF component.

Add this to your page :

<h:inputHidden value="#{EditorBean.value}" id="editorValue"/>

and onblur of editor textarea assign the value to the hidden element using

document.getElementById(editorValue).value = this.value;
like image 63
niksvp Avatar answered Oct 18 '22 01:10

niksvp


Since this question bumped up somehow....

There is another option:

You can use the PrimeFaces Extensions , here is the link PrimeFaces Extensions CKEditor

Here an example from the showcase

<p:growl id="growl" showDetail="true" />  
<pe:ckEditor id="editor" value="#{editorController.content}" interfaceColor="#33fc14">  
    <p:ajax event="save" listener="#{editorController.saveListener}" update="growl"/>  
</pe:ckEditor>  

<p:commandButton actionListener="#{editorController.changeColor}" update="editor"  
      value="Change color with AJAX" style="margin-top:10px;"/> 
like image 27
Daniel Avatar answered Oct 17 '22 23:10

Daniel