struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Tremal Naik" <>
Subject JSTL formatNumber and Locale
Date Fri, 21 Apr 2006 09:42:00 GMT
I use the following syntax into a jsp page:

<fmt_rt:formatNumber groupingUsed="true" var="minInc" scope="page"
minFractionDigits="1" maxFractionDigits="1"
<nested:text property="minIncome" value="${minInc}" />

The minIncome is initially defined into the scenarioForm as something
similar to an ordinary double, i.e. 2.0

The double is displayed into the minIncome text field as 2,0
accordingly to my regional settings. Ok

When the action defined for this form is executed the form minIncome
property value is converted to a numeric format. Ok

But... when I submit the form the validate() method is executed. If it
returns some errors, the request is redirected to the original page
before any regional-to-numeric conversion is performed, so now the
formatNumber tag doesn't like the format of the minIncome property:

2006-04-19 09:29:45,967 [http-] ERROR [ROM] [USER:
tremal] javax.servlet.jsp.JspException: In &lt;formatNumber&gt;, value
attribute can not be parsed into java.lang.Number: "2,0"

How can I solve this? I would immediately convert the value in the
scenarioForm.setMinincome() method, if the http request object was
somehow available, as this method is called before the validate().
Infact, I need to know the user Locale to parse the string to a number
correctly (do I?). I may convert the value in the validate() itself
before proceeding with the validations, but I don't like this
solution, as it's advised against performing other than simple
validation in that. I may define an additional form field with the
user locale read from the request, but I'd rather use a smarter

Any suggestions?


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message