commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Craig R. McClanahan" <>
Subject Re: [beanutils] not finding the setter
Date Wed, 02 Jul 2003 20:21:07 GMT

On Wed, 2 Jul 2003, Kenneth Stout wrote:

> Date: Wed, 2 Jul 2003 12:50:14 -0700
> From: Kenneth Stout <>
> Reply-To: Jakarta Commons Users List <>
> To: Jakarta Commons Users List <>
> Subject: Re: [beanutils] not finding the setter
> I hadn't tried making the base property boolean. But my tests show that a
> boolean works with both a get<PropertyName> and is<PropertyName> specified.
> Its a String based property that will not work. Very interesting.
> So I guess my question for the community would is, should BeanUtils be
> enhanced to handle the is<PropertyName> descriptor that is returned by
> java.beans.Introspector or should it stay conforming to the "letter of the
> standard"?

The mission of BeanUtils is to provide extended support for JavaBeans.
While there are some things above and beyond plain JavaBeans that are
supported, they are done so in a style that is similar to the way things
work with standard JavaBeans, in order to maximize knowledge transfer and
minimize surprises.

Doing what it sounds like you are suggesting (allowing a String setter and
a boolean getter for the same property name), though, would violate one of
the core characteristics of JavaBeans -- what a "property" is, and how it
is recognized.  Any support for such a thing in BeanUtils would *not* get
reflected into the hundreds of other applications that use standard Java
introspection to acquire property getter and setter information.
Therefore, I think this woud be an exceedingly bad idea, and will -1 a
proposal to implement it.

You should make sure that your JavaBean is really a JavaBean if you expect
BeanUtils to help you utilize it.  One common approach is to use two
different property names in your bean class - something like:

  public boolean isFoo();
  public void setFoo(booean foo);
  public String getFooAsString();
  public void setFooAsString(String fooAsString);

and link the two internally (by doing the appropriate conversions).

Craig McClanahan

View raw message