0

I have the following confirm dialog

<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>

and call the confirm like the following,

<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>

It works fine as i expected but the confirm dialog is called before even server side validation happens.

in my case i am trying to validate password and confirm password change and just giving the alert to confirm that the user really wants to change it.

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
Joe
  • 4,460
  • 19
  • 60
  • 106

1 Answers1

0

You have (at least) two options:

  1. Send the password fields to the server via ajax and have validation done in that roundtrip. If 'OK' enable the commandLink which then has the confirmDialog in it.

  2. Don't use a confirmDialog but a normal dialog. That on clicking the commandLink is shown if there is no validation like in here: How to display dialog only on complete of a successful form submit

I personally prefer option 1

Community
  • 1
  • 1
Kukeltje
  • 12,223
  • 4
  • 24
  • 47