jsf - p :editor shows "true" on initial page load

标签 jsf primefaces rich-text-editor

我在一个简单的表单中插入了一个编辑器组件,当加载网页而不是预定义的文本(问号)时,我看到了 true 这个词。在编辑器中。

我试图从模板中删除 html 特殊字符,查看另一个 SO 答案(其中大部分是关于 <p:ajax> 而不是 <f:ajax> 并将编辑器放在对话框中,这里不是这种情况)。我正在使用 PrimeFaces 5.2。

我的 Controller :

@ViewScoped
@ManagedBean(name = "mailTemplateBean")
public class MailTemplateBean extends BaseWebBean {

    @PostConstruct
    public void init() {
        text = "?????????????";
    }

    private String text;

    public String getText() {
        return text;
    }

    public void setText(String text) {
        this.text = text;
    }
}

我的看法:
<h:form id="form">
    <p:editor id="editor" widgetVar="editorWidget"
        value="#{mailTemplateBean.text}" width="600" />
    <p:commandButton value="Update" update="editor"
        icon="ui-icon-disk" />

</h:form>

更新:Chrome 和 Firefox 的行为不同。 Chrome - 开始时编辑器已禁用且为空。只有当我点击命令按钮时 - 它才会刷新并显示正确的文本。上面所描述的 - 这是它在 Firefox 中的工作方式(或不工作方式)。

最佳答案

我不确定这是否是它的工作方式,但我解决了将以下行放入表单中的问题:

<p:remoteCommand name="rc" update="editor" autoRun="true"/>

它在页面加载后刷新编辑器,并正确显示来自支持 bean 的值。

关于jsf - p :editor shows "true" on initial page load,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33260128/

相关文章:

jsf - 在 Java EE 中手动启动新线程安全吗?

java - JSF 2.2 java.lang.IllegalStateException : Cannot create a session after the response has been committed

java - 如何在 JSF 中动态添加字段?

jsf - p :dataTable with p:cellEditor tab behaviour

jsp - 提交 dijit 编辑器内容

ajax - JSF ajax从下拉列表中重新加载整个页面

javascript - Primefaces PF函数

java - 仅针对特定组件的 ajaxStatus

objective-c - 图形图像保存在文本编辑器中?

python - 强调文本编辑器?