2016-04-08 120 views
0

我需要更改p:confirmDialog的默認行爲。在點擊Yes按鈕,它已經完成了請求傳球值1,點擊上,不,它已經完成了一個請求傳遞值0更改p的默認行爲:confirmDialog

<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

請,你可以把豆動作代碼嗎? – hlucasfranca

+0

下面的答案解決了。謝謝。 –

回答

1

非全局模式與用於簡單客戶端api,show()和hide()的對話框組件幾乎相同。參考Primefaces用戶指南5.3頁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> 

PF java script function

測試與JSF 2.2.4,Primefaces 5.3

+0

這是工作。謝謝。 –