On Fri, 2006-09-22 at 17:30 +0300, Ilja S. wrote:
> Hello
> Could you please explain why i get "JspException: Wrong format string: 
> '###,###.00' " when I use <bean:write formatKey="global.format"> when 
> other then "EN" locale is in user's session?
> 
> At the same time if use "format" tag <bean:write format="###,###.00"> 
> then no matter what locale is in session it is working fine AND do 
> format according to locale
> 
> Thanks in advance

Ilja,

Tere!

This is the expected behavior.  I'm not sure what version of Struts
you're using, but you can check out the source for the (1.x)
<bean:write> tag here:

http://svn.apache.org/viewvc/struts/struts1/trunk/taglib/src/main/java/org/apache/struts/taglib/bean/WriteTag.java?view=markup

The relevant part is from lines 330 to 348 (indenting modified):

if (formatString != null) {
  try {
    format = NumberFormat.getNumberInstance(locale);

    if (formatStrFromResources) {
      ((DecimalFormat) format).applyLocalizedPattern(
        formatString);
    } else {
      ((DecimalFormat) format).applyPattern(formatString);
    }
  } catch (IllegalArgumentException e) {
    JspException ex =
      new JspException(messages.getMessage(
          "write.format", formatString));

    TagUtils.getInstance().saveException(pageContext, ex);
    throw ex;
  }
}

There seems to be some discussion of this in the Struts JIRA system:

http://issues.apache.org/struts/browse/STR-1865?page=all

See Ted Husted's comments.  Of course, he's talking about the date (not
number) formatting, but it only serves to highlight the distinction
between the handling of the two types.  Note that if you look at the
code immediately following what is quoted here, you'll see that the
SimpleDateFormat constructor is *always* passed the locale.

I found all this stuff by Googling various combinations of "WriteTag",
".applyLocalizedPattern", and "IllegalArgumentException"

Hea õnn!

Chris

-- 
Christopher D. Goldman
[EMAIL PROTECTED]
415.962.4884


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to