Hello Ted,

Tuesday, December 05, 2000, 5:59:58 PM, you wrote:

TH> Do you think Thor's Validation code could be extended to use the
TH> standard i18n mechanism for number and date formatting, but regex for
TH> others?

I found this mechanism not ideal... More useful can be model where
fields and validation rules for it defined in config file for struts
not directly in classes or in jsp pages.
There we can define separate field sections or incorporate it to the
form sections. With each field section we can define all data needed
to to validate input values.

Now I use import/export methods in form beans to converse data to/from
String values.

 public void importEntity( EntityBean value,
   HttpServletRequest request, ActionErrors errors )
   throws ServletException {}
 public EntityBean exportEntity( EntityBean value,
   HttpServletRequest request, ActionErrors errors )
   throws ServletException {}

For each time bean with data used as source to populate
form fields (with i18n support) and at save moment export method is
called to populate bean with data from form bean. All conversion
errors this mechanism stores in standart errors container. This is not
ideal. Problem is hard coded conversions. Each conversion is some
strings of code, where DateFormat or NumberFormat classes are used to
import/export values. I think that all conversion logic can be
incorporated to BeanUtils and instead of separate set/get callings
populate method with automatic values conversions on i18n basis can be
used. All rules for this conversions can be stored in struts config
file and retrieved by the digester. For example, some fields of form
are defined in struts config file and all conversions with it can be
performed by BeanUtils in automatic mode. Some count of fields has
set/get methods too, but are not defined in struts config - this
fields would be populated in old manner and can be Strings only. But
all it is a raw idea...
But there are already exists some such solutions in my pocket.. 8) One
of them - bean:format tag, which derived from bean:write tag to
support properties printing with i18n support. Number, date, time
values can be printed with it. For special cases I can specify special
format and print values in special manner. I glad to pass it to the
community.

-- 
Best regards,
 Oleg                            mailto:[EMAIL PROTECTED]


Reply via email to