我需要更改p:confirmDialog的默认行为。单击是按钮,它已完成请求传递值1,单击否,它已完成传递值0的请求。
<p:commandButton value="Consultar" onclick="consultar.show()">
<p:confirmDialog id="consultar" message="Foi feito a venda de recarga para esse cliente?" header="Confirmação" severity="alert" widgetVar="consultar">
<p:commandButton id="confirmaBtn" value="Sim" oncomplete="consultar.hide()" action="#{notaFiscalBean.consultarNota}">
<f:setPropertyActionListener target="#{notaFiscalBean.temRecarga}" value="1" />
</p:commandButton>
<p:commandButton id="recusaBtn" value="Não" oncomplete="consultar.hide()" action="#{notaFiscalBean.consultarNota}">
<f:setPropertyActionListener target="#{notaFiscalBean.temRecarga}" value="0" />
</p:commandButton>
</p:confirmDialog>
</p:commandButton>
此解决方案无效。任何人都知道如何解决这个问题?
答案 0 :(得分:1)
非全局模式与用于简单客户端api,show()和hide()的对话框组件几乎相同。参考Primefaces用户指南5.3 Page 121。
<p:commandButton value="Consultar" onclick="PF('consultar').show()"></p:commandButton>
<p:confirmDialog id="consultar"
message="Foi feito a venda de recarga para esse cliente?"
header="Confirmação" severity="alert" widgetVar="consultar">
<p:commandButton id="confirmaBtn" value="Sim"
oncomplete="PF('consultar').hide()"
action="#{notaFiscalBean.consultarNota}">
<f:setPropertyActionListener target="#{notaFiscalBean.temRecarga}"
value="1" />
</p:commandButton>
<p:commandButton id="recusaBtn" value="Não"
oncomplete="PF('consultar').hide()"
action="#{notaFiscalBean.consultarNota}">
<f:setPropertyActionListener target="#{notaFiscalBean.temRecarga}"
value="0" />
</p:commandButton>
</p:confirmDialog>
使用JSF 2.2.4,Primefaces 5.3进行测试