commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Craig R. McClanahan" <>
Subject Re: [beanutils] WrapDynaBean.set() method to use conversions...
Date Thu, 30 May 2002 16:25:55 GMT

On Thu, 30 May 2002, James Strachan wrote:

> Date: Thu, 30 May 2002 06:43:26 +0100
> From: James Strachan <>
> Reply-To: Jakarta Commons Developers List <>
> To: Jakarta Commons Developers <>
> Subject: [beanutils] WrapDynaBean.set() method to use conversions...
> I'd really like it if the set(String name, Object value) method on the
> WrapDynaBean would convert Strings to primitive types automatically. Without
> this conversion its possible to get a strange exception saying that a "write
> property does not exist", when really the issue is that a String was passed
> into a numeric/boolean property by accident.
> Now I could implement this behaviour by implementing a derivation of
> WrapDynaBean, say called ConvertingWrapDynaBean (bit of a mouthful). Though
> I'd far more prefer the default behaviour of WrapDynaBean to be able to do
> primitive type conversions. Afterall the great strength of using dyna beans
> is they can be used generically and work nicely in servlet / XML style
> environments where things are mostly text.
> Its a fairly trivial change; rather than calling
> PropertyUtils.setSimpleProperty(bean, propertyName, value) we can call the
> (now public) BeanUtils.setProperty(bean, propertyName, value) which does
> type conversions.
> I've already got a patch for this which I'll commit if folks agree. Does
> this sound reasonable?

While it sounds like a very useful mechanism, I've got three concerns
about modifying WrapDynaBean to do this:

* Consistency with standard JavaBeans - property setters here have
  no support for conversion; you have to do it ahead of time

* Inconsistency between setter (with conversion) and getter (without)

* Performance - The BeanUtils.setProperty() method will take longer in all
  of the cases where conversion is NOT required.

I'd be +1 for something like ConvertingWrapDynaBean for people that want
behaves this way, but don't really like the idea of modifying the existing
functionality (since it's now been released).

> James


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

View raw message