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

Leonardo Uribe commented on MYFACES-2857:
-----------------------------------------

1. Is this a desired behavior?

Ans: I checked it and it is a bug. Since FacesMessage provide setDetail and 
setSummary methods, it should be possible to change the summary and detail.

2. In MyFaces 1.1.7 a FacesMessage was used instead of a 
ParametrizableFacesMessage, is there a configurable way to runtime use a 
FacesMessage instead of a ParametrizableFacesMessage? 

Ans: Maybe the best we can do is provide some public methods to manipulate the 
params that were used to construct ParametrizableFacesMessage. The tricky part 
is this class is spread everywhere, from myfaces core, shared, commons and 
tomahawk, so it is necessary to unify it in all possible places. In that way, 
it should be possible to call those methods using reflection or if there is 
access to the one in shared, cast and call them. 

3. I suppose another workaround would be to add a label argument to each 
component which will be evaluated by the ParametrizableFacesMessage, is there 
any documentation how this functionality is intended to work? 

Ans: See JSF spec (1.2 or 2.0) section 2.5.2.4. The problem is the label is 
added as a param but the order is not always the same.

To solve the problem described, it is necessary to override setSummary() and 
setDetail() to reset the evaluated summary and detail one and add two methods 
getUnformattedSummary() and getUnformattedDetail(). It is not necessary to 
reset evaluatedArgs array, because the change that needs to be supported is on 
summary and detail message. In this way it is possible to provide an alternate 
summary and detail that could use the original parameters. I think this is the 
most consistent behavior. 

> Its not possible to change the summary/ detail message of a 
> ParametrizableFacesMessage
> --------------------------------------------------------------------------------------
>
>                 Key: MYFACES-2857
>                 URL: https://issues.apache.org/jira/browse/MYFACES-2857
>             Project: MyFaces Core
>          Issue Type: Bug
>          Components: General
>    Affects Versions: 1.1.8
>            Reporter: Jerry Meurs
>
> We are using a PhaseListener in the render response phase to change the 
> summary message of a FacesMessage
> {code}
> public void beforePhase(PhaseEvent phaseEvent) {
>    ...
>   Iterator componentMessages = facesContext.getMessages(clientId);
>    while (componentMessages.hasNext()) {
>      FacesMessage message = (FacesMessage)componentMessages.next();
>      StringBuilder builder = new StringBuilder();
>      builder.append(label);
>      builder.append(message.getSummary());
>      message.setSummary(builder.toString());
>   }
> }
> {code}
> The problem is that since MyFaces 1.1.8 a ParametrizableFacesMessage is used 
> for required messages. While doing a getSummary() the _evaluatedSummary is 
> evaluated once, so effectively you can not change the _evaluatedSummary after 
> one call to getSummary().
> My questions:
> 1. Is this desired behaviour?
> 2. In MyFaces 1.1.7 a FacesMessage was used instead of a 
> ParametrizableFacesMessage, is there a configurable way to runtime use a 
> FacesMessage instead of a ParametrizableFacesMessage?
> 3. I suppose another workaround would be to add a label argument to each 
> component which will be evaluated by the ParametrizableFacesMessage, is there 
> any documentation how this functionality is intended to work?

-- 
This message is automatically generated by JIRA.
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to