Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

FacesMessage and ValidationMessages

 
Wander Soares
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How can i know if a FacesMessage is a Validation Message?
 
Victor Hugo M Machado
Greenhorn
Posts: 22
Eclipse IDE Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
getSeverity() donĀ“t help you?


maybe I misunderstood what you call "Validation Message"
 
Cesar Loachamin
Ranch Hand
Posts: 90
Chrome Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi wandroide

I was thinking about your question.

First, when a error ocurrs when the component are validanting or converting the request value in the phase of Process Validations the jsf-impl throws a ConverterException or ValidatorException that excepction is catch in the component that add a FacesMessage with the severity set a FacesMessage.SEVERITY_ERROR, for that you can't use the severity property to identify the cause of the FacesMessage as suggested by Victor Hugo.

All Standar Validation message errors start with Validation Error this can serve to help identify a FacesMessage for a validation error

Since JSF 1.2 you can use in the components that implements the EditableValueHolder interface as h:inputText the converterMessage and validatorMessage this you can use to show a message when a conversion or validation ocurrs.

Regards

Cesar.
 
Wander Soares
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My problem is how can i know if a FacesMessage is a ValidationException in the BackingBean. Because we start the exception passing as parameter the FacesMessage, and that one is added in the FacesContext. Seeing each FacesMessage one by one i need to know if it is a message that is originally a ValidationException.
 
Cesar Loachamin
Ranch Hand
Posts: 90
Chrome Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok, wandroide I think I understand you, but here you have a problem the FacesMessage is designed to be a general class, since any developer can use this class to show any message (regardless of whether validation error messages or conversion) in the redered page whith the help of <h:message> or <h:messages>, and for that reason FacesMessage don't have properties to indicate the reason of the message.
As I was saying in the previous post the most standar validation message errors contians the word Validation Error, except for RegexValidator that contains Regex Patter or BeanValidator, you can use this to identify if the message was produced for a ValidatorException.

Regards

Cesar
 
Wander Soares
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic