【发布时间】:2020-11-24 14:24:27
【问题描述】:
我有一个带有 PrimeFaces 的 JSF 应用程序,我正在更新到 PrimeFaces 版本 8(当前使用版本 7)。
更新后,我在对话框中使用 TextEditor 时出现了奇怪的行为。我使用 commandLink 打开对话框并更新对话框以刷新其内容。当我这样做时,我在 JavaScript 控制台上得到一个错误。
texteditor.js.xhtml?ln=primefaces&v=8.0:7 Uncaught TypeError: Cannot read property 'innerHTML' of null
at e.value (texteditor.js.xhtml?ln=primefaces&v=8.0:7)
at new e (texteditor.js.xhtml?ln=primefaces&v=8.0:7)
at texteditor.js.xhtml?ln=primefaces&v=8.0:7
at Array.map (<anonymous>)
at e.value (texteditor.js.xhtml?ln=primefaces&v=8.0:7)
at e.value (texteditor.js.xhtml?ln=primefaces&v=8.0:7)
at e.value (texteditor.js.xhtml?ln=primefaces&v=8.0:7)
at texteditor.js.xhtml?ln=primefaces&v=8.0:7
at Array.forEach (<anonymous>)
at e.value (texteditor.js.xhtml?ln=primefaces&v=8.0:7)
错误来自代码:
a(e.prototype.__proto__ || Object.getPrototypeOf(e.prototype), "selectItem", this).call(this, t, n), t = t || this.defaultItem, this.label.innerHTML = t.innerHTML
其中 t 为 null,因此 t.innerHTML 会引发错误。
但是 - 如果我只打开对话框而不更新它 - 一切正常。
我创建了一个最小样本。第一个 fink 工作正常,第二个链接会产生错误。
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:p="http://primefaces.org/ui"
xmlns:h="http://java.sun.com/jsf/html"
>
<h:head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type"/>
<title>test</title>
</h:head>
<h:body>
<h:form id="contentForm">
<p:commandLink value="works"
oncomplete="PF('dialogTemplateSendMailToPersonVar').show()"/>
<br/>
<p:commandLink value="does not work"
oncomplete="PF('dialogTemplateSendMailToPersonVar').show()"
update=":templatePersonSendMailForm"/>
</h:form>
<p:dialog id="dialogTemplateSendMailToPersonId" widgetVar="dialogTemplateSendMailToPersonVar" dynamic="true">
<h:form id="templatePersonSendMailForm">
<p:textEditor id="txtTemplateText" />
</h:form>
</p:dialog>
</h:body>
</html>
在此示例中,更新没有用,但会产生与我的完整页面相同的错误,其中我有填充编辑器和对话框中其他字段的支持 bean。
有没有人经历过类似的事情或知道如何解决这个问题?我查看了 PrimeFaces 8.0.x 版本的发行说明,但没有发现 TextEditor 有任何问题。不更新对话框不是一种选择;-)
【问题讨论】:
-
其实貌似是这个问题:github.com/quilljs/quill/issues/1762
标签: jsf primefaces