jsf - p:textEditor : 默认值
问题描述
我使用 PrimeFaces 的 textEditor 组件,字符串变量 (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);
}
解决方案
我相信您的问题与此问题的修复有关: 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;
},
推荐阅读
- javascript - Javascript 会先加载,即使代码位于标签末尾
- android - 如何从 NFC 标签中获取纯文本?
- python - 在 Python > 3.4 中从文件加载模块的正确方法
- c++ - 将 char* 传递给函数并在内存中覆盖它
- c - CodeLite 配色方案(主题)搞砸了 C
- c# - c#空缺的测试任务,但我学过java)
- ios - 如何在集合视图中更改视图的颜色
- python - 如何让我的代码循环重复?
- anylogic - 模型逻辑错误:如果我不放置队列块,我的模型将不起作用,但是这个块会减慢进程
- java - 在 java netbeans 和 mysql 中插入数据时出错