BeanUtils.copyProperties() method does not work with date fields.
One needs to copy it manually using DateFormatter ot something. To avoid
garbage getting into date variable in domain object, one should name it
other way.
For example, if domain object has : Date paymentDate; you should rename the
variable for this date in form as datePayment so that it does not get copied
to domain object.
-Original Message-
From: Leandro Melo [mailto:[EMAIL PROTECTED]
Sent: Wednesday, September 08, 2004 10:21 AM
To: struts jakarta
Subject: ActionForm data type X BeanUtils - using Dates
Hi,
i believe that a lot of developers use BeanUtils to
copy the data from ActionForms to the specific DTOs.
I've used this approach, but right now i'm facing a
problem, not a big one.
I've allways been confused about working with dates in
Java. I got a jsp where the user must input a date in
the following format.
Date: dd/mm/
That's how we use dates in Brazil: the day, month and
year.
I'd like to make a validation if the user input the
date in the correct manner in the ActionForm (i'm
using traditional validation and the user input comes
in a String). So, keeping in mind the variou ways of
doing this date validation (even the deprecated ones),
how should a do the date validation Which one is
the best way??? I just want to check if the user input
a day with 2 digits, a slash, a month with 2 digits,
a slash and a year with 4 digits.
Also, after that i'd like to copy this form data to my
DTO with BeanUtils. Which type should i use in my DTO
for this date???
Thanks,
Leandro.
___
Yahoo! Acesso Grátis - navegue de graça com conexão de qualidade!
http://br.acesso.yahoo.com/
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]