File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSF and the fly likes FacesMessage and ValidationMessages Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "FacesMessage and ValidationMessages" Watch "FacesMessage and ValidationMessages" New topic
Author

FacesMessage and ValidationMessages

Wander Soares
Greenhorn

Joined: Jun 18, 2010
Posts: 10
How can i know if a FacesMessage is a Validation Message?
Victor Hugo M Machado
Greenhorn

Joined: Jan 11, 2011
Posts: 22

getSeverity() donĀ“t help you?


maybe I misunderstood what you call "Validation Message"
Cesar Loachamin
Ranch Hand

Joined: Dec 25, 2010
Posts: 90

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.


When a dream is ending because to come true - OCPJP 6,7. OCE JPA EE6. MCTS
Wander Soares
Greenhorn

Joined: Jun 18, 2010
Posts: 10
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

Joined: Dec 25, 2010
Posts: 90

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

Joined: Jun 18, 2010
Posts: 10
Thanks.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: FacesMessage and ValidationMessages