【发布时间】:2011-09-05 11:29:43
【问题描述】:
我在使用 Primefaces 触发 ajax 请求时遇到问题
<f:metadata>
<f:viewParam name="token" value="#{clientBean.token}"/>
<f:event type="preRenderView" listener="#{clientBean.getParameter}" />
</f:metadata>
<h:form>
<h:graphicImage id="id1" url="/images/circle-ok.png" onclick="dTag.show();"/>
<p:commandButton id="id4" value="T" actionListener="#{clientBean.tag}" />
<!-- This does not work -->
<h:graphicImage id="id2" url="/images/circle-ok.png">
<p:ajax id="id3" event="onclick" onstart="dTag.show();"
actionListener="#{clientBean.tag}" />
</h:graphicImage>
</h:form>
第一个h:graphicImage正确打开对话框,p:commandButton正确触发actionListener,但p:ajax没有效果(在googles应用引擎上测试)。
更新 1
将 event 从 onclick 更改为 click 绝对正确(感谢 BalusC):现在显示了 p:dialog。但仍然没有调用tag() 方法。我已经用f:metadata 更新了xhtml-Code,因为还有一个额外的日志记录。
我认为它与 p:ajax 和 bean 的调用有关,我尝试过 actionListener、action 和 listener(来自Primefaces)具有相同的结果:
- 应用引擎记录
getParameter(ComponentSystemEvent event)的调用,Firebug 显示此部分更新:<changes><update id="otCounter"><![CDATA[<span id="otCounter">0</span>]]></update>.. - 没有记录
public void tag(ActionEvent ae)的调用(也尝试过public void tag())
p:commandButton 正确更新计数器。
更新 2
为了简单起见,我删除了f:viewParam 和f:event,现在使用listener 和public void tag(),但没有调用该方法:-(
更新3 BalusC的回答是正确的,我这里使用的时候还有其他问题:JSF and p:ajax inside p:dataTable inside ui:repeat
【问题讨论】:
标签: java google-app-engine jsf primefaces