• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

display error message

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I am new to JSF and trying to figure out a way to display a message in a jsf page. Once the submit button is clicked the action method performs validation. The next step is to go back to the same page with an error message showing what went wrong. Any help would be greatly appreciated!

Thanks in advance!
Piers
 
Saloon Keeper
Posts: 27763
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the JavaRanch, Piers!

There are 2 message-display JSF tags, One is for a single control (message for="ctlId") and the other is for messages in general (<h:messages>). To add your own custom messages, you can obtain the FacesContext in your action processor, create a Faces Message object, and add it to the FacesContext messages collection using JSF API calls.

JSF's built-in validation framework will run before the action processor is invoked. Items which fail built-in validators will be flagged with error messages and the action processor won't be invoked, so if you're adding "second-stage" validation in the action processor, it will only be run if the primary validations all succeed.
 
piers morgan
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the help Tim! I was able to display messages using the solution you mentioned.

 
reply
    Bookmark Topic Watch Topic
  • New Topic