• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

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

 
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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

  •  
    Ranch Hand
    Posts: 200
    Eclipse IDE Java Ubuntu
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    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.
     
    Greenhorn
    Posts: 12
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Hi,

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

     
    Greenhorn
    Posts: 4
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Can this be done using Javascript on the page?
     
    What does a metric clock look like? I bet it is nothing like this tiny ad:
    Clean our rivers and oceans from home
    https://www.kickstarter.com/projects/paulwheaton/willow-feeders
    reply
      Bookmark Topic Watch Topic
    • New Topic