我正在使用 JSF 2、Glassfish 3.1、PrimeFaces 3.5。我从主页复制了使用PF 4.0的演示。我删除了 PF 函数来使用我的 PF 版本。
这是我的代码:
<h:form id="form">
<p:editor id="editor" value="#{editorBean.value}" width="600"/>
<h:panelGrid columns="2" style="margin-top:10px">
<p:commandButton id="submitButton" value="Submit" update="display" oncomplete="dlg.show()"
icon="ui-icon-disk" />
<p:commandButton id="clearButton" type="button" value="Clear" onclick="editor.clear()"
icon="ui-icon-close" />
</h:panelGrid>
<p:dialog header="Content" widgetVar="dlg" showEffect="fade" hideEffect="fade" modal="true">
<h:outputText id="display" value="#{editorBean.value}" escape="false" />
</p:dialog>
</h:form>
“提交”按钮运行良好,但我无法使用“清除”按钮清除编辑器文本。 PF 3.5支持clear方法吗?希望有人推荐我。
最佳答案
您尚未指定 widgetVar 属性。因为它会获取用于清除编辑器部分的 widgetVar 值,而不是您案例中的 id。
应该是这样。
<p:editor id="editor" value="#{editorBean.value}" widgetVar="editor" width="600" />
关于java - PrimeFaces 3.5 编辑器无法清除文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20487255/