Oleg V Alexeev wrote:

> Hello Ted,
>
> In my application I use import/export methods in Form classes. For the
> first time I try to use PropertyUtils.copyProperties(), but this
> method convert properties without locale choosing. I need to process
> different time/date and number formats for different languages.
> Because of it I use my own methods to convert values to String and
> from String to values.
> I think that locale must be used to convert values in
> PropertyUtils.copyProperties() and in <bean:write> tag.
> If anybody can suggest another way, plesase, I am very interested in
> it.
>

We're talking futures in terms of Struts here, but my question is ... aren't you
doing the Locale-specific conversion a little bit too early?

My thinking is that business logic objects maintain data objects in a
Locale-insensitive format (like java.util.GregorianCalendar or
java.math.BigDecimal).  And, the ActionForm properties would be of the same
type.  Conversion to or from String would happen at the last minute -- just as
you prepare the page for display, or as you are accepting the input.

Admittedly, we need better support in Struts (such as your formatting version of
<bean:write>, and a way to process the input string with PropertyEditor type
classes) to make this strategy really effective, but I would suggest not doing
the Locale-specific formatting until you have to.

Craig


Reply via email to