Hi,
The reason that this feature isn't present in SetPropertiesRule is that
SetPropertiesRule just builds a map of (attrname,attrvalue) pairs then
calls BeanUtils.populate(...), and BeanUtils.populate doesn't support
reporting an error if a map entry has no matching setter method.
I think to add this you will need to modify the beanutils library. From
a brief look, BeanUtils.populate calls BeanUtils.setProperty for each
map entry, but BeanUtils.setProperty has this code:
try {
descriptor =
PropertyUtils.getPropertyDescriptor(target, name);
if (descriptor == null) {
return; // Skip this property setter
}
} catch (NoSuchMethodException e) {
return; // Skip this property setter
}
So if no setter method is found, the property is just ignored.
NB: Robert, would you mind using bottom-posting instead of top-posting?
I wanted to comment on bits of both Gabriele's and your mail, but when
someone has already top-posted a reply it is hard to do that.
Cheers,
Simon
On Fri, 2004-09-03 at 06:34, robert burrell donkin wrote:
> the easiest way to achieve this would be to download the source and
> then add a line or two that does that! you can then replace your
> modified jar with the standard version when you're ready for
> production.
>
> - robert
>
> On 2 Sep 2004, at 16:23, Gabriele Carcassi wrote:
>
> > Hi,
> >
> > Is there a way to configure the SetPropertyRule to throw an exception,
> > or to
> > alert me in some way, when a property set in the XML is not found in
> > the
> > bean?
> >
> > This is typically useful when a user mispells the property for a bean
> > whose
> > class is defined at runtime (thus I can't use schema). For example:
> > <building type="buildings.Sky" featerColor="yellow" />
> >
> > Do I have to create my rule or I am missing something?
> >
> > Thanks,
> > Gabriele
> >
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]