2013-08-06 59 views

回答

1

我能夠重現你的情況,你可以做到以下幾點:

  • 讓你的對話框closable="false"
  • 添加將隱藏對話框的Cancel按鈕。
  • 在您的取消按鈕中添加Primefaces Extensions中的resetInput組件。這將清除表單驗證和值。

下面是一個假設您的對話框爲widgetVar,名爲wvDialog的示例。

<p:commandButton value="Cancel" immediate="true" onclick="wvDialog.hide()"> 
     <pe:resetInput for="myDialogFormId /> 
    </p:commandButton> 

你甚至可以調用bean方法在按鈕actionListener如果你需要。

我希望它有幫助。

+1

感謝您的好評!按鈕我真的想要一個關閉按鈕在右上角...... – ethanjyx

+0

我有一個*取消*按鈕在'oncomplete ='PF(「wvDialog」)。hide();''。但是,當我打開對話框時,它會顯示錯誤消息。 –

0

每次提交表單時都更新p:dialogp:message
您可以使用更新屬性p:commandButton

<p:commandButton update="ID_OF_DIALOG" /> 
7

您應該在必須打開對話框的元素上使用p:resetInput

例如,如果您使用的是p:commandButton

<p:commandButton value="Open dialog" update=":dialogId" oncomplete="PF('dialogWidget').show()" > 
    <p:resetInput target=":dialogId" /> 
</p:commandButton> 

這將在打開的對話框中的緩存值(包括驗證消息)復位。

相關問題