SimpleMessage calling MessageFormat with replacement parameters when there are 
none
-----------------------------------------------------------------------------------

                 Key: STS-789
                 URL: http://www.stripesframework.org/jira/browse/STS-789
             Project: Stripes
          Issue Type: Bug
          Components: Formatting
    Affects Versions: Release 1.5
            Reporter: Rick Grashel


When using message bundles with <fmt:message> tags or using ordinary Java calls 
to get ResourceBundle messages, there is a very specific behavior with regards 
to single-quotes and replacement parameters.  

By default, if <fmt:message> is used without replacement parameters ( 
<fmt:param> ), then the MessageFormat class is not used to render the message.  
This means that escaping of single-quotes (with two single-quotes) is not 
necessary for messages without replacement args.  Here is the relevant excerpt 
of Apache's MessageSupport.java class (which is extended by the MessageTag):

...
message = bundle.getString( key );
// Perform parametric replacement if required
if ( !params.isEmpty() )
{
            Object[] messageArgs = params.toArray();
            MessageFormat formatter = new MessageFormat( "" ); // empty 
pattern, default Locale
            ...
            formatter.applyPattern( message );
            message = formatter.format( messageArgs );
}
...

The SimpleMessage in Stripes is always using the MessageFormat class to render 
messages.  Because of this, there is a behavior inconsistency with regards to 
single-quotes.  If you have a property declared in StripesResources as:

my.property.key=This Is The User's Message

The above property will be rendered as "This Is The User's Message" by 
<fmt:message>.  However, SimpleMessage will render this message as "This Is The 
Users Message".  SimpleMessage will strip out the single-quote.  This is 
inconsistent behavior and means that quoted property messages cannot be re-used 
seamlessly between Stripes and regular JSTL <fmt> tags.

The necessary fix is for SimpleMessage to only use MessageFormat for rendering 
messages if the replacementParameters passed into it have a length greater than 
zero.

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

        

------------------------------------------------------------------------------
What happens now with your Lotus Notes apps - do you make another costly 
upgrade, or settle for being marooned without product support? Time to move
off Lotus Notes and onto the cloud with Force.com, apps are easier to build,
use, and manage than apps on traditional platforms. Sign up for the Lotus 
Notes Migration Kit to learn more. http://p.sf.net/sfu/salesforce-d2d
_______________________________________________
Stripes-development mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/stripes-development

Reply via email to