Hello,
I wanted to use the new <bean:write> format mechanism,
I specified my format strings in the message resources.
So far so good ... everything was fine, but when I changed the
user locale with Action.setLocale() nothing happend for
FLOAT_FORMAT_KEY.
The Problem is in
org.apache.struts.taglib.bean.WriteTag.formatValue(...)
after line 318.
Please watch my comment.
if (formatStr == null) {
format = NumberFormat.getInstance(locale);
} else {
try {
//Here we don't use the user locale but the JVM default locale.
format = new DecimalFormat(formatStr);
} catch (IllegalArgumentException _e) {
JspException e = new
JspException(messages.getMessage("write.format", formatStr));
RequestUtils.saveException(pageContext, e);
throw e;
}
}
I changed it to this, and it did work well.
if (formatStr == null) {
format = NumberFormat.getInstance(locale);
} else {
try {
//here we use the user locale
NumberFormat f = NumberFormat.getNumberInstance(locale);
if (f instanceof DecimalFormat) {
((DecimalFormat) f).applyPattern(formatStr);
format = f;
} else {
format = new DecimalFormat(formatStr);
}
} catch (IllegalArgumentException _e) {
JspException e = new
JspException(messages.getMessage("write.format", formatStr));
RequestUtils.saveException(pageContext, e);
throw e;
}
}
Is this a Bug ??
Or am I missunderstanding something ?
Volker
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>