p:textEditor:默认值<p> <br/> </p>

时间:2018-06-12 05:21:37

标签: jsf primefaces text-editor

我使用PrimeFaces的textEditor组件,String变量(JEE)包含输入的文本。 当我在调用组件之前使用“null”或“”初始化此变量时,此变量随后包含:<p><br></p> 结果,不显示占位符,光标位于第二行。 如何删除此值?

这是我的代码:

    <p:contextMenu>
                <p:menuitem value="Ajouter une note" actionListener="#{noteManagerBean.initialiserNote()}" 
                            oncomplete="PF('widgetNoteDialog').show()" 
                            update="idNoteDialog"/>
            </p:contextMenu>

            <p:dialog id="idNoteDialog" widgetVar="widgetNoteDialog" style="position: absolute; border: none; border-radius: 0; z-index: 2" class="effetZoom" showEffect="fade" hideEffect="fade" closable="false" resizable="false"> 
                <p:textEditor placeholder="Entrez votre texte ici" value="#{noteManagerBean.noteTexte}" height="129" style="width: 294px; position: absolute; top: 0px; left: 12px; margin-left: -1px; background-color: transparent">
                    <f:facet name="toolbar"> 
                        <span class="ql-formats">
                            <button class="ql-bold"></button>
                            <button class="ql-italic"></button>
                            <button class="ql-underline"></button>
                        </span>
                    </f:facet>
                </p:textEditor>
</p:dialog>

@SessionScoped
@Named
public class NoteManagerBean implements Serializable {

    private String noteTexte;

    public void initialiserNote() {

        setNoteTexte(null);

    }

1 个答案:

答案 0 :(得分:1)

我相信您的问题与此问题的修复有关:https://github.com/primefaces/primefaces/issues/3170

它试图确定编辑器是否已经显示HTML。

getEditorValue: function() {
        var html = $(this.editorContainer[0]).find('p').text();
        var value = (html == '<p><br></p>') ? '' : html;

        return value;
    },