[jbossseam-issues] [JBoss JIRA] Commented: (JBSEAM-3451) FacesMessages.createFacesMessageFromRessourceBundle interpolates twice the message (the first time being wrong)

Stephane Epardaud (JIRA) jira-events at lists.jboss.org
Tue Sep 23 08:12:20 EDT 2008


    [ https://jira.jboss.org/jira/browse/JBSEAM-3451?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12430768#action_12430768 ] 

Stephane Epardaud commented on JBSEAM-3451:
-------------------------------------------

Furthermore, by looking at Interpolator.interpolate() I wonder how I could produce a left curly brace in my message. MessageFormat is pretty clear (although hard to understand) on how to produce curly braces and how to quote them, but I don't see any such handling in Interpolator.interpolate.

For instance I doubt that Interpolator.interpolate("'''{0}'''") would produce "{0}" rather than "'''{0}'''".

http://download.java.net/jdk7/docs/api/java/text/MessageFormat.html

> FacesMessages.createFacesMessageFromRessourceBundle interpolates twice the message (the first time being wrong)
> ---------------------------------------------------------------------------------------------------------------
>
>                 Key: JBSEAM-3451
>                 URL: https://jira.jboss.org/jira/browse/JBSEAM-3451
>             Project: Seam
>          Issue Type: Bug
>    Affects Versions: 2.0.1.GA
>            Reporter: Stephane Epardaud
>
> If I call FacesMessages.addMessageFromResourceBundle("key", 3) with in my resource bundle:
> key={0,choice,0#foo|0<bar}
> I get "3" instead of "bar".
> This is because in FacesMessages.createFacesMessage(Severity severity, String key, String defaultMessageTemplate, Object... params) the message is gotten from the SeamResourceBundle with calls Interpolator.interpolate("{0,choice,0#foo|0<bar}") (with NO parameter), which returns "{0}" because of the lack of parameters.
> Then later on in FacesMessages.createFacesMessage(Severity severity, String messageTemplate, Object... params) the expected interpolation happens again and calls Interpolator.interpolate("{0}", 3) which returns "3" naturally.
> I really doubt this double interpolation of message formats is wanted. Suppose that the first interpolation of EL "#{foo}" would return a string like "#{bar}", the second interpolation would evaluate "#{bar}" even though this might not be the desired behaviour.
> In any case double interpolation breaks MessageFormat formatting (which is supposed to be handled) and I'm not sure it is documented. If it is expected behaviour it is really not clear to me why someone would want that.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://jira.jboss.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the seam-issues mailing list