You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Adam Lipscombe <ad...@expensys.com> on 2007/06/13 18:23:26 UTC
Handling international number and date formats in html:text fields
Folks,
We have an internationalised site using struts 1.3.8.
We output currency and number values to the JSP with the bean:write tag and this works well.
The problem comes when the user is entering numbers, currency and dates via an html:text field.
Ideally it would be nice if the conversion to US/UK format was handled automatically so any
subsequent parsing and arithmetic would work. I cant find any way to get the html:text tag to do
this - various texts I hav read suggest that it is locale-sensitive but if I put a "format" or
"formatKey" attribute in the tag the poage does not compile.
It occurs to me that this must be a generic issue.
Is there a standard solution for handling input of numbers and dates in non-US format?
If so what is it?
If the conversion cannot be automatic is it best handled or in the action or actionform?
Thanks - Adam
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Handling international number and date formats in html:text fields
Posted by Laurie Harper <la...@holoweb.net>.
Adam Lipscombe wrote:
> Folks,
>
> We have an internationalised site using struts 1.3.8.
> We output currency and number values to the JSP with the bean:write tag
> and this works well.
>
> The problem comes when the user is entering numbers, currency and dates
> via an html:text field.
>
> Ideally it would be nice if the conversion to US/UK format was handled
> automatically so any subsequent parsing and arithmetic would work. I
> cant find any way to get the html:text tag to do this - various texts I
> hav read suggest that it is locale-sensitive but if I put a "format" or
> "formatKey" attribute in the tag the poage does not compile.
Well, according to the documentation [1], that tag doesn't support
format or formatKey attributes. You would need to first format the data
via other means (a combination of bean:define and bean:write, for
example, or using the JSTL formatting tags/functions), then supply the
formatted data via html:text's value attribute.
Here's one possibility (untested):
<c:set var="num">
<fmt:formatNumber value="${someData} pattern="..."/>
</c:set>
<html:text name="someprop" value="${num}"/>
> It occurs to me that this must be a generic issue.
> Is there a standard solution for handling input of numbers and dates in
> non-US format?
> If so what is it?
>
> If the conversion cannot be automatic is it best handled or in the
> action or actionform?
I'd say in the action personally, though that's really a matter of
preference.
L.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org