commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Gabriele Carcassi" <carca...@netbeans.org>
Subject Re: digester: can SetPropertyRule warn on not found properties?
Date Tue, 07 Sep 2004 17:05:03 GMT
Hi Simon and Robert,

Thanks for the answers.

I had a look at the source and it seems that in dev an exception is thrown:
http://jakarta.apache.org/commons/beanutils/xref/org/apache/commons/beanutils/BeanUtilsBean.html#1013
but it doesn't seem to block the Digester processing... anyway, I don't 
think I will have problem finding why.

Once I am done, would you like the patch to be contributed back? If so, is 
it ok if it depends on the latest version of beanutil?

Gabriele


"Simon Kitching" <simon@ecnetwork.co.nz> wrote in message 
news:1094163840.9347.34.camel@pcsimon...
> 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: commons-user-unsubscribe@jakarta.apache.org
>> > For additional commands, e-mail: commons-user-help@jakarta.apache.org
>> >
>> >
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: commons-user-help@jakarta.apache.org
>>
>> 




---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Mime
View raw message