commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject [BeanUtils] setProperty() calls toString() when calling a converter
Date Tue, 17 Aug 2004 16:24:36 GMT
I have been registering new converters to deal with conversions between
strings and other types such as dates. Converters are triggered based on
the type of the destination property which is being set. This means that
even if i am setting a property of type "Date" with a value of type "Date"
it always gets passed through my registered date converter first. I only
wanted strings values to be passed through the converter. To get around
this i placed come checks in the converter to first check the type of the
value being passed in, so that dates would be ignored.
When using copyProperties() between two beans, the conversions worked fine
but when a colleague of mine was using BeanUtils.populate() we ran into
problems. He was trying to set a Date property with a Date value but it was
hitting the date converter and failing. Having looked at the source code
for BeanUtilsBean i found the following code in the setProperty() method

else if (getConvertUtils().lookup(value.getClass()) != null) {
                newValue = getConvertUtils().convert(value.toString(),

getConvertUtils().convert delegates to my date converter but passes it a
string. This means that my type checking in the converter fails. Why is is
set to behave like this when copyProperty() beahves as expected?



Disclosure of Material Facts
Every Proposer or Insured / Reinsured when seeking new insurance / reinsurance or renewing
an existing Policy must disclose any information which might influence the Insurer / Reinsurer
in deciding whether or not to accept the risk, what the terms should be, or what premiums
to charge.  Failure to do so may render the insurance / reinsurance voidable from inception
and enable the Insurer / Reinsurer to repudiate liability.

This email, together with any attachments, is for the exclusive and confidential use of the
addressee(s) and may contain legally privileged information.  Any other distribution, use
or reproduction without the sender's prior consent is unauthorised and strictly prohibited.
 If you have received this message in error, please notify the sender by email immediately
and delete the message from your computer without making any copies.  While attachments are
virus checked, Aon Limited does not accept any liability in respect of any virus which is
not detected.

Aon Limited
Company Number: 210725
Registered Address: 8 Devonshire Square, London, EC2M 4PL

Aon Limited is a member of the General Insurance Standards Council (registration 2239)

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message