使用CKEditor而不是PrimeFaces Editor

nen*_*eni 6 jsf ckeditor primefaces jsf-2

我试图在我的JSF应用程序中使用CKEditor.如何将CKEditor的内容转换为支持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>
Run Code Online (Sandbox Code Playgroud)

BackingBean

@ManagedBean公共类EditorBean {

private String value;

public String getValue() {
    return value;
}

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

}

当我尝试打印该值时,它不打印.在这个问题上帮助我.PrimeFaces Editor不支持"插入表"功能.所以,我想使用CKE.

nik*_*svp 7

因为el无法评估非JSF组件.

将其添加到您的页面:

<h:inputHidden value="#{EditorBean.value}" id="editorValue"/>
Run Code Online (Sandbox Code Playgroud)

onblur编辑器使用textarea的值将值分配给隐藏元素

document.getElementById(editorValue).value = this.value;
Run Code Online (Sandbox Code Playgroud)


Dan*_*iel 6

因为这个问题不知何故......

还有另一种选择:

您可以使用PrimeFaces Extensions,这里是PrimeFaces Extensions CKEditor的链接

这里展示了一个例子

<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;"/> 
Run Code Online (Sandbox Code Playgroud)