I have a JSF 2.0 page that uses Primefaces p:dialog component. The user can enter information in the dialog and click save/cancel. If they have a validation error, it is shown on the dialog. When they close or cancel the dialog, I want any p:message components to be "wiped out", i.e. so that if the user then opens p the dialog again, they wont see old validation messages.
Use case is: user opens dialog, doesnt fill all required fields, clicks Save, required field error messages are shown in the dialog. User clicks cancel which closes the dialog. User then clicks the button to open up the dialog again. I dont want them to see the previous validation messages (which currently they can).
Ajax-update the dialog component before opening it.
E.g.
<p:commandButton ... update=":dialog" oncomplete="dialog.open()" />
It will not only clear messages, but also input field values (or at least preserve them with right defaults).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With