How can I clear error messages? Not sure if I'm doing this right.
Rob Micah
Ranch Hand
Joined: Aug 30, 2011
Posts: 68
posted
0
I have a page that displays a form and when it's submitted it displays a PDF report. The user might back up multiple times to re-submit this form to see the report with different parameters. If the user makes a mistake by entering invalid data the page fails validation and displays errors. If the user then corrects those errors and re-submits the form, the report will run. But if they back up after submitting the form those old errors from the previous submission are still displayed. I am looking for a way to clear the errors in the <h:messages> tags from the page when the user backs up. Is there any way to do this?
As an example here's a description of what happens:
User visits url for first time
User submits form with invalid data
Validation fails and re-displays page populating <h:message> tags
You should discourage the use of the back button and instead allow them to go back using a commandLink or button on the page. That forces the app to cycle through the JSF life cycle and clear the message queue.
Bertjan Underhill
Greenhorn
Joined: Aug 25, 2008
Posts: 12
posted
0
Hi,
try this, add the next line of code after the user re-submits the form (in the methode of your backingbean):