Hello Craig,
Thursday, January 11, 2001, 9:46:45 PM, you wrote:
CRM> We're talking futures in terms of Struts here, but my question is ... aren't you
CRM> doing the Locale-specific conversion a little bit too early?
CRM> My thinking is that business logic objects maintain data objects in a
CRM> Locale-insensitive format (like java.util.GregorianCalendar or
CRM> java.math.BigDecimal). And, the ActionForm properties would be of the same
CRM> type. Conversion to or from String would happen at the last minute -- just as
CRM> you prepare the page for display, or as you are accepting the input.
CRM> Admittedly, we need better support in Struts (such as your formatting version of
CRM> <bean:write>, and a way to process the input string with PropertyEditor type
CRM> classes) to make this strategy really effective, but I would suggest not doing
CRM> the Locale-specific formatting until you have to.
We start work at struts 0.5 stage and found some troubles with
non-String properties for Form beans. Because of it I break classes to
the groups: 1-form beans (String only properties) and 2-data beans
(with such types of properties as Integer, Date, etc.). Action class
fills form bean with values from data bean and make locale specific
conversion at this stage. User fills form with new values and submit
it to the save action. Save action takes String values from form and
make conversion to the internal representation (Integer, Date, etc.)
There are two variants to perform conversion to/from form beans -
place all logic in set/get methods in form or incorporate
import/export methods to the form beans and call it on phase of init
or submit. But locale specific conversion needs to be performed with
current locale and value of current locale must be retrieved every
set/get calling. And because of it I make import/export methods, where
is place to perform all locale specific operations - retrieve locale,
retrieve format beans, convert values to/from String.
For my mind it is most effective way to perform tranlation, but I
don't like this scheme... Can you pass some words about another
solution, if you have one?
--
Best regards,
Oleg mailto:[EMAIL PROTECTED]