Reputation: 2069
I have a required input field in a p:dialog
. If firstly I submit nothing for the field, a validation error happens on that field. Then I close the dialog and reopen it, the validation error still exists. What can I do to eliminate the validation error when close the dialog?
Upvotes: 14
Views: 8833
Reputation: 2326
You should use the p:resetInput
on the element that you have to open the dialog.
For example if you use a p:commandButton
<p:commandButton value="Open dialog" update=":dialogId" oncomplete="PF('dialogWidget').show()" >
<p:resetInput target=":dialogId" />
</p:commandButton>
This will reset the cached values (including the validation messages) upon opening the dialog.
Upvotes: 14
Reputation: 11608
I was able to reproduce your case and you could do the following:
closable="false"
.Cancel
button that will hide the dialog.Here is an example that assumes your dialog as a widgetVar
named wvDialog
.
<p:commandButton value="Cancel" immediate="true" onclick="wvDialog.hide()">
<pe:resetInput for="myDialogFormId />
</p:commandButton>
You could even call a bean method in the button actionListener
if you need.
I hope it helps.
Upvotes: 3
Reputation: 8151
Update the p:dialog
or p:message
every time you submit the Form.
You can do that by using update attribute of p:commandButton
.
<p:commandButton update="ID_OF_DIALOG" />
Upvotes: 0