我尝试将primefaces应用于我的项目。我创建了一个测试页来演示ajax。调用了侦听器,但UI组件未使用新值更新。
我正在使用Primefaces 4。
这是我的代码(我在这里展示了相同的内容:http://www.primefaces.org/showcase/ui/ajax/poll.xhtml):
<h:form id="testForm">
<h:outputText id="txt_count" value="A: #{testBean.number}" />
<p:poll interval="30" listener="#{testBean.increment}" update="testForm:txt_count" />
<p:ajaxStatus style="width:16px;height:16px;">
<f:facet name="start">
<h:panelGroup style="margin-top:5;" styleClass="statusBar">
<h:graphicImage value="/images/ajax-busy.gif" style="width:15;height:15;margin:0;padding:0;"/> Checking...
</h:panelGroup>
</f:facet>
<f:facet name="stop">
<h:panelGroup style="margin-top:5;" styleClass="statusBar">
<h:outputText value=" " style="width:15;height:15;"/>
</h:panelGroup>
</f:facet>
</p:ajaxStatus>
</h:form>
我在Firefox上调试并获得响应:
<?xml version="1.0" encoding="utf-8"?><partial-response><changes><update id="testForm:txt_count"><![CDATA[<span id="testForm:txt_count">A: 1</span>]]></update><update id="javax.faces.ViewState"><![CDATA[rO0ABXVyABNbTGphdmEubc3Npb25... too long ...weHNxAH4CcAApQ==]]></update>
并出现此错误:
XML解析错误:找不到元素位置: moz-nullprincipal:{2b3608be-0d4d-4533-8ca1-52b28a98a16d}行号 1,第56128栏:
... AfgG1cQB + AbVxAH4BtXBweHhweHhxAH4BpQ ==]] GT; ...----------------------------------------------- - ^
您可以看到响应xml缺少<partial-response>
和<changes>
的结束标记
你能帮我找出根本原因吗?
============================================ ================================== 通过从应用程序中删除richfaces解决了上述问题 ================================================== ============================
更新: 这适用于Firefox但不适用于IE。
以下是我得到的内容:http://i.stack.imgur.com/qq6m8.png