• 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 ...
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Paul Clapham
  • Devaka Cooray
  • Ron McLeod
  • paul wheaton
Saloon Keepers:
  • Tim Moores
  • Piet Souris
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Al Hobbs
  • Frits Walraven
  • Scott Selikoff

How can I get the rendered text of a FacesMessage server side?

Ranch Hand
Posts: 365
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all-
I'm writing some custom validation code and want to piggy back on JSF. I'm using the resources file for my message templates but in certain cases want to handle the rendering differently. Ideally I would create a FacesMessage with my msg template and parms and then extract the completed msg text server side. Is there any way I can do this with JSF?
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You mean like--generate your own faces error and use a message bundle for the error message??
protected void getBundleMsgSetError(String key) {
// Look up the requested message text

try {
ResourceBundle bundle = ResourceBundle.getBundle(
"some.prop.file.Msgs", getFacesContext()
text = bundle.getString(key);
} catch (Exception e) {
// Construct and add a FacesMessage containing it
new FacesMessage(FacesMessage.SEVERITY_ERROR, text, text));

//or just make a new Faces message when you need to:

new FacesMessage(FacesMessage.SEVERITY_ERROR,
getMsg(), getMsg()));
Police line, do not cross. Well, this tiny ad can go through:
the value of filler advertising in 2021
    Bookmark Topic Watch Topic
  • New Topic