File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSF and the fly likes How can I clear error messages? Not sure if I'm doing this right. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "How can I clear error messages? Not sure if I Watch "How can I clear error messages? Not sure if I New topic
Author

How can I clear error messages? Not sure if I'm doing this right.

Rob Micah
Ranch Hand

Joined: Aug 30, 2011
Posts: 94
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
  • User corrects form data and submits
  • PDF is output
  • User presses back button and sees old errors

  • Guy deLyonesse
    Ranch Hand

    Joined: Apr 12, 2011
    Posts: 200

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

    try this, add the next line of code after the user re-submits the form (in the methode of your backingbean):



    ><((((º>`·.¸¸.·´¯`·.¸.·´¯`·...¸><((((º>`·.¸¸.·´¯`·.¸¸.·´¯`·.. ><((((º>`·.¸¸.·´¯`·.¸.·´¯`·...¸><((((º>
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: How can I clear error messages? Not sure if I'm doing this right.
     
    Similar Threads
    Setting and removing session attributes - is this the right way to do this?
    Preventing form resubmission on Back button
    Preventing form resubmission on Back button
    Maintain Data Across Errors
    Struts 2 : Does s:reset is really capable for reset ?