You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Pedro Herrera <pe...@hotmail.com> on 2007/10/23 22:56:55 UTC

[s2] number format s:textfield tag

Hi,
   I have a currency input field (BigDecimal). In my location the decimal
point is comma, eg, 10,00(==10.00) must be permitted.  Struts is throwing a
message error : Invalid field value for field "valor".


Thanks

Herrera


-- 
View this message in context: http://www.nabble.com/-s2--number-format-s%3Atextfield-tag-tf4680318.html#a13373598
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: [s2] number format s:textfield tag

Posted by Eduard Neuwirt <ed...@googlemail.com>.
Hi,

This is very diffcult issue in struts. First you have to set your locale
correctly. Second you have to use in the jsp the correct calls for number
formatting. The struts docummenattion explains this point in FAQ (I hold in
mind so). Alternatively you can write your own converter for BigDecimal.
I would prefer the first way.

Regards
Eduard

2010/3/30 Juanjo C <jj...@gmail.com>

> Any idea?
>
> 2007/10/23 Pedro Herrera <pe...@hotmail.com>
>
> >
> > Hi,
> >   I have a currency input field (BigDecimal). In my location the decimal
> > point is comma, eg, 10,00(==10.00) must be permitted.  Struts is throwing
> a
> > message error : Invalid field value for field "valor".
> >
> >
> > Thanks
> >
> > Herrera
> >
> >
> > --
> > View this message in context:
> >
> http://www.nabble.com/-s2--number-format-s%3Atextfield-tag-tf4680318.html#a13373598
> > Sent from the Struts - User mailing list archive at Nabble.com.
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > For additional commands, e-mail: user-help@struts.apache.org
> >
> >
>

Re: [s2] number format s:textfield tag

Posted by Rene Gielen <gi...@it-neering.net>.
Hi,

see
http://struts.apache.org/2.1.8.1/docs/formatting-dates-and-numbers.html

It is important to know that Struts 2 has always a locale context
request for each request, which affects both formating and parsing dates
and numbers. The request locale is determined as follows:

1. Request parameter
(http://struts.apache.org/2.1.8/docs/i18n-interceptor.html)
2. Session attribute
(http://struts.apache.org/2.1.8/docs/i18n-interceptor.html)
3. Browser preference
4. Server side JVM default

The first matching lookup wins.

The type conversion mechanism tries to parse dates and numbers in the
current locale context, thus you should be fine when you ensure that you
have a consistent locale request setting both for the first request
(rendering the form and the current value in the textfield) and the
second request (processing the submitted form).

- René

Juanjo C schrieb:
> Any idea?
> 
> 2007/10/23 Pedro Herrera <pe...@hotmail.com>
> 
>> Hi,
>>   I have a currency input field (BigDecimal). In my location the decimal
>> point is comma, eg, 10,00(==10.00) must be permitted.  Struts is throwing a
>> message error : Invalid field value for field "valor".
>>
>>
>> Thanks
>>
>> Herrera
>>
>>
>> --
>> View this message in context:
>> http://www.nabble.com/-s2--number-format-s%3Atextfield-tag-tf4680318.html#a13373598
>> Sent from the Struts - User mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
> 

-- 
René Gielen
IT-Neering.net
Saarstrasse 100, 52062 Aachen, Germany
Tel: +49-(0)241-4010770
Fax: +49-(0)241-4010771
Cel: +49-(0)163-2844164
http://twitter.com/rgielen

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: [s2] number format s:textfield tag

Posted by Greg Lindholm <gr...@gmail.com>.
In my experience it's better to define number (and time) input fields
as String and perform the conversion and validation in your action
using java.text.NumberFormat .  This puts you in control of the
process and let's you handle I18N issues that way you want to without
fighting Struts.

I typically have a couple of helper methods I put into the base Action
class that simplify getting the users Locale and NumberFormat.
Depending on the app the users Locale may come from a Login object or
the browser request (which Struts can retrieve) or from a cookie.

On Tue, Mar 30, 2010 at 5:56 AM, Juanjo C <jj...@gmail.com> wrote:
> Any idea?
>
> 2007/10/23 Pedro Herrera <pe...@hotmail.com>
>
>>
>> Hi,
>>   I have a currency input field (BigDecimal). In my location the decimal
>> point is comma, eg, 10,00(==10.00) must be permitted.  Struts is throwing a
>> message error : Invalid field value for field "valor".
>>
>>
>> Thanks
>>
>> Herrera
>>
>>
>> --
>> View this message in context:
>> http://www.nabble.com/-s2--number-format-s%3Atextfield-tag-tf4680318.html#a13373598
>> Sent from the Struts - User mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: [s2] number format s:textfield tag

Posted by Juanjo C <jj...@gmail.com>.
Any idea?

2007/10/23 Pedro Herrera <pe...@hotmail.com>

>
> Hi,
>   I have a currency input field (BigDecimal). In my location the decimal
> point is comma, eg, 10,00(==10.00) must be permitted.  Struts is throwing a
> message error : Invalid field value for field "valor".
>
>
> Thanks
>
> Herrera
>
>
> --
> View this message in context:
> http://www.nabble.com/-s2--number-format-s%3Atextfield-tag-tf4680318.html#a13373598
> Sent from the Struts - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>