[ 
https://issues.apache.org/jira/browse/MYFACES-4051?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15343891#comment-15343891
 ] 

Leonardo Uribe commented on MYFACES-4051:
-----------------------------------------

I have checked the spec and there is a clarification in JSF 2.2 section 6.3 
that doesn't really say much:

"... The presence of one or more FacesMessage instances on the FacesContext 
indicates a failure of some kind during the lifecycle. In particular, a 
validation or conversion failure is required to cause a FacesMessage to be 
added to the FacesContext. ..."

The patch is valid and can be committed. In fact, the ERROR severity is set 
when the ValidatorException instance is created (By default through 
_MessageUtils.getErrorMessage(...)), so there is no need to set it again.

The point is if there is a validation error, the values on the input fields 
must be preserved when the table is rendered, otherwise they could get lost. I 
just wanted to be sure the change did not affect that logic.

This patch needs to be applied in 2.0.x, 2.1.x, 2.2.x and 1.2.x.

> FacesMessage.Severity always set to ERROR after ValidatorException
> ------------------------------------------------------------------
>
>                 Key: MYFACES-4051
>                 URL: https://issues.apache.org/jira/browse/MYFACES-4051
>             Project: MyFaces Core
>          Issue Type: Bug
>    Affects Versions: 2.2.10
>         Environment: Tomcat, WebSphere Liberty
>            Reporter: Bill Lucy
>         Attachments: MYFACES-4051.patch
>
>
> The severity of messages is always set (overwritten) to SEVERITY_ERROR when a 
> ValidatorException is thrown during validation.  In 
> org.apache.myfaces.view.facelets.compiler._ComponentUtils I see that we 
> always call 
> facesMessage.setSeverity(FacesMessage.SEVERITY_ERROR);
> when processing a ValidatorException.  This might make sense if we're 
> assuming that all faces messages default to some other severity, but it 
> doesn't seem right to me that we're overwriting user-set message severities.  
> For example, given the following custom validator:
>       public void validate(FacesContext context, UIComponent component, 
> Object value) {
>               if (value == null) {
>                       List<FacesMessage> messageList = new ArrayList<>();
>                       messageList.add(new 
> FacesMessage(FacesMessage.SEVERITY_INFO,
>                               "ValidatorException#SEVERITY_INFO", 
> "ValidatorException#SEVERITY_INFO"));
>                       throw new ValidatorException(messageList);
>               }
>       }
> The severity of the custom message will always be set to SEVERITY.ERROR.  I 
> don't see much guidance in the spec on this, but Mojarra behaves differently 
> - it does not overwrite custom FacesMessage severities.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to