2016-07-28 13 views
0

我有以下confirm dialog撥打號碼:confirmDialog只在成功驗證在JSF

<p:confirmDialog global="true" showEffect="fade" hideEffect="fade" header="Modal Dialog" modal="true" width="430" height="120" > 
      <p:commandButton value="Ok" type="button" styleClass="ui-confirmdialog-yes myButton" icon="ui-icon-check" style="float:right;font-family:verdana, Arial; font-size:10pt; color:#ffffff; font-weight:bold;text-align:center;"/> 
      <p:commandButton value="Cancel" type="button" styleClass="ui-confirmdialog-no myButton" icon="ui-icon-close" style="float:right;font-family:verdana, Arial; font-size:10pt; color:#ffffff; font-weight:bold;text-align:center;"/> 
     </p:confirmDialog> 

,並致電確認類似下面,

<p:commandLink style="text-decoration: none;" global="false" action="#{resetPasswordWindowController.changePassword()}" update="@form" > 
         <p:panelGrid id="loginButtonGrid" layout="tabular" styleClass="loginButtonGrid" > 
          <p:row styleClass="loginButtonGridRow"> 
           <p:column styleClass="loginButtonGridText lighterGreenBackground roundLeftCorners" > 
             Reset 
           </p:column> 
          </p:row> 
         </p:panelGrid> 
         <p:confirm header="Reset Password" message="Are you sure?" icon="ui-icon-alert" /> 
        </p:commandLink> 

它正常工作,如我所料,但確認在服務器端驗證發生之前調用對話框。

在我的情況下,我正在嘗試驗證密碼並確認密碼更改,並給出提醒以確認用戶真的想要更改它。

Expected Results would be : 

1. Validate the password and confirm password and if they are valid only show the confirm dialog and proceed to save based on the confirmation we get from confirm dialog. 

Thanks 

回答

0

你有(至少)兩個選項:

  1. 通過AJAX發送密碼字段到服務器,並有驗證在往返完成。如果'OK'啓用commandLink,然後在其中包含confirmDialog。

  2. 不要使用confirmDialog,而是使用普通對話框。上單擊commandLink顯示,如果有喜歡這裏沒有驗證:How to display dialog only on complete of a successful form submit

我個人比較喜歡選項1