Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Can you set a global FacesMessage on a required component?

 
Rob Micah
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have an h:inputText component in my facelet with the "required" attribute set to true. Is there a way to set a global FacesMessage for when this fails? It sets one for the component by default.
 
Hebert Coelho
Ranch Hand
Posts: 754
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Put this in your prorpeties file.

javax.faces.component.UIInput.REQUIRED="My Global Message"
 
Rob Micah
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Right now I'm not getting a global message at all even though I have

at the top of my facelet. However I do have

underneath the h:inputText it corresponds to.

So I do get a message just not a global one.
 
Rob Micah
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To be more specific what I am asking is, why am I not already seeing a global message for this error even though I have an h:messages tag in my facelet with the globalOnly attribute set to true?
 
Cesar Loachamin
Ranch Hand
Posts: 90
Chrome Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Rob

Remove the globalOnly=true, that is wrong, when you set this attribute to true you only show messages not associated with a commponent, the global messages are added using the FacesContext.addMessage.
Kind regards
C├ęsar.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic