从 PrimeFaces 7 更新到 8 后对话框中的 PrimeFaces TextEditor 出现问题
Problem with PrimeFaces TextEditor in Dialog after update from PrimeFaces 7 to 8
我有一个带有 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 为空,因此 t.innerHTML 抛出错误。
但是 - 如果我只打开对话框但不更新它 - 一切正常。
我创建了一个最小样本。第一个 fink 工作正常,第二个 link 产生错误。
<!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 有任何问题。不更新对话框不是一个选项 ;-)
好的,问题已在 6.2 中修复:https://github.com/primefaces/primefaces/issues/2802
然而,当 QuillJS 1.3.7 升级为安全 CVE 时,此更改丢失。
我刚刚提交了一个 PR 来解决这个问题,希望能在 8.0.4 和 9.0 中使用。
我有一个带有 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 为空,因此 t.innerHTML 抛出错误。
但是 - 如果我只打开对话框但不更新它 - 一切正常。
我创建了一个最小样本。第一个 fink 工作正常,第二个 link 产生错误。
<!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 有任何问题。不更新对话框不是一个选项 ;-)
好的,问题已在 6.2 中修复:https://github.com/primefaces/primefaces/issues/2802
然而,当 QuillJS 1.3.7 升级为安全 CVE 时,此更改丢失。
我刚刚提交了一个 PR 来解决这个问题,希望能在 8.0.4 和 9.0 中使用。