Try writing your own utils class extending BeanUtils. You can either
check all input variables for null, or check datatype first, then check
for null only on those properties you wish to allow 'null-ok'. You can
still take advantage of BeanUtils by calling super.X(property, value),
or super(dest, src) on anything that passes your validation.
Possibilities are endless.

Another option, which I don't like myself, is having a default date in
your app new date(0)- defaults to 1974(?), that you can ignore elsewhere
in your app (e.g. - put it in your DAO, so it doesn't write the bad date
to the DB table, but clears the value first) This second option litters
the code with exception handling, which I would only do as a last
resort.

Duane

-----Original Message-----
From: rahul [mailto:[EMAIL PROTECTED] 
Sent: Monday, September 26, 2005 10:03 AM
To: Jakarta-Struts-List
Subject: problem in Beanutils.copyProperties()

Hi all,

I am having a problem in using copyProperties() of
org.apache.commons.beanutils.BeanUtils class

I am doing it in this way

BeanUtils.copyProperties(destBean,srcBean)

where destBean and srcBean both have a property by name date,

which is of type java.sql.Timestamp()

If date property of srcBean is set to null then the above statement
gives

an exception: "BeanUtil.ConversionException: No value specified"

It works fine in case srcBean.date is properly initialized.

But there is a possibility of having null in srcBean.date in my code.

So, how to deal with this?





--RahulJoshi




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to