Hi
Thanks for reply but I'm still confused
What you mean "expected behavior"? In link to bugzilla you provided this is considered as a bug and it says it is fixed in Struts 1.2 family.
I'm using 1.2.9
As I understood this tag should format according to current locale.
All I want that numbers were formatted for users, and I don't want do this in business layer or in ActionForm. And seems that "format" property of <bean:write> is working correct while "formatKey" is not, even if I have resource file for other non-"en" locale.

So if this is expected behavior and NOT a bug, how then use this tag?

Thanks in advance

Christopher Goldman wrote:
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



--
*************************************
Best Regards
Ilja


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

Reply via email to