struts-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From <hermod.opstv...@dnbnor.no>
Subject RE: SV: Struts 1.3 and Internationalization
Date Thu, 30 Mar 2006 05:54:56 GMT
Hi

And now we have come full circle: You suggest to use Strings in forms, but if you do - do
not blame Struts? 

So, lets stick with Struts, and use Double and Floats etc. We know that this does not work
because of RequestUtils. So my statement stills stands: Struts does not do I18N properly.

Hermod

-----Original Message-----
From: mfncooper@gmail.com [mailto:mfncooper@gmail.com]On Behalf Of
Martin Cooper
Sent: Thursday, March 30, 2006 7:46 AM
To: Struts Developers List
Subject: Re: SV: Struts 1.3 and Internationalization


On 3/29/06, hermod.opstvedt@dnbnor.no <hermod.opstvedt@dnbnor.no> wrote:
>
> Hi
>
> Martin, Hubert : I am using Strings only in my forms, and using BeanUtils
> to populate my VO's. However, consider what Joe is writing here about
> Converters and scope. Not only that, Converters are not! localeware. I have
> had to hack them in order to support a comma decimal separator


Perhaps, but doesn't that make this a BeanUtils question rather than a
Struts question? If you're doing the conversion from strings using BeanUtils
yourself, I guess I'm not sure what the relationship is to Struts and i18n.

--
Martin Cooper


from DoubleConverter.convert:
>
>           ...
>         if (value instanceof Double)
>         {
>             return (value);
>         }
>         else if (value instanceof Number)
>         {
>             return new Double(((Number) value).doubleValue());
>         }
>
>           if(value instanceof String)
>           {
>                 value = ((String) value).replace('.',',');
>           }
>           ...
>
> Since the Converters implement an interface, it might be possible to
> implement them in so that they have a reference to for instance a request
> scoped class that holds a reference to the current request, and is
> instantiated by a filter. This would mean creating a very simple filter
> who's only responsibility was to get the locale from the request, and put
> this into a static ThreadLocal variable ( I do this to hold hibernate
> sessions in a pre-Spring application). This way the converter could ask that
> class to serve it the locale.
>
> And by the way: Referring to another project such as formdef to solve a
> problem that inherently lies within Struts does not help Struts become
> better.
>
> Hermod
>
> -----Original Message-----
> From: mfncooper@gmail.com [mailto:mfncooper@gmail.com]On Behalf Of
> Martin Cooper
> Sent: Thursday, March 30, 2006 12:46 AM
> To: Struts Developers List
> Subject: Re: SV: Struts 1.3 and Internationalization
>
>
> On 3/29/06, Hubert Rabago <hrabago@gmail.com> wrote:
> >
> > On 3/29/06, Joe Germuska <Joe@germuska.com> wrote:
> > > I started to believe this, but now I disagree.
> > >
> > > It is only solvable with the current code if your application runs in
> > > one Locale.  Struts does not provide a way to register instantaneous
> > > conversion parameters (like the current Locale) -- registering a
> > > converter with ConvertUtils has application-wide (actually JVM-wide)
> > > scope, and would not be correct in the case that the same application
> > > was handling floats that would have different decimal separators (to
> > > use Hermod's example).
> > >
> > > The active locale must be passed in to RequestUtils.populate(...),
> > > and in this case, compatibility seems like a lame excuse.
> > >
> > > Here's where the action happens:
> > >
> > > entrance to RequestUtils.populate(...):
> > >
> >
> http://struts.apache.org/struts-action/xref/org/apache/struts/util/RequestUtils.html#341
> > >
> > > The actual place where ActionForm properties are set:
> > >
> >
> http://struts.apache.org/struts-action/xref/org/apache/struts/util/RequestUtils.html#451
> > >
> > > I see no reason why all this code couldn't be pushed to a method
> > > which takes a locale as an argument, and this method amended to call
> > > that one with the system default locale.
> >
> > I would agree if we weren't recommending that people use Strings in
> > the ActionForm [1].
>
>
> Exactly. The "best practice" ever since Struts was created has been to use
> strings for form fields, specifically so that you have the exact original
> value to present to the user in an error situation. Once you bring other
> data types into the picture, you can no longer guarantee that you can
> redisplay exactly what the user (mis-)typed.
>
> --
> Martin Cooper
>
>
> What I'm saying is that your form should have String values and
> > RequestUtils.populate() will populate it whatever your user typed in,
> > and then in your Action you can use BeanUtils or FormDef to properly
> > parse that into your business object typed field.
> >
> > You can see this in action in the locale.war demo of FormDef [2].
> >
> > > Joe
> >
> > Hubert
> >
> > [1] "... properties used with the html:text tag should still be String
> > properties."
> >
> http://struts.apache.org/struts-action/userGuide/building_controller.html#dyna_action_form_classes
> > [2] http://www.rabago.net/struts/formdef/downloads.htm
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
> > For additional commands, e-mail: dev-help@struts.apache.org
> >
> >
>
>
> * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
> *
>
> This email with attachments is solely for the use of the individual or
> entity to whom it is addressed. Please also be aware that DnB NOR cannot
> accept any payment orders or other legally binding correspondence with
> customers as a part of an email.
>
> This email message has been virus checked by the virus programs used
> in the DnB NOR Group.
>
> * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
> *
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
> For additional commands, e-mail: dev-help@struts.apache.org
>
>

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


Mime
View raw message