FTI, Jelly has a feature like just SetPropertiesRule in a tag called
useBean. 

I converted this tag from BeanUtils.populate to a combination of isWritable
and copyProperty/copyProperties and all unit tests ran and several big Maven
script also worked. Although I haven't uploaded the patch for this change.

Maybe all of commons should release this conversion at once, so that people
are simply forced to adapt to it across the board. :)

Seriously, though, I really think that it'll work fine for you. I walked
through the populate code and all I could find was stuff that honestly
doesn't apply to XML processing. For instance, populate will handle a
attribute with a "." in the name: <tag foo.bar="baz" /> will set the bean
property .getFoo().setBar("baz") where "baz" is converted to the proper
argument type. This is obviously meant for HTTP variable processing, not XML
attributes.

Do you really want this feature? If not, I'd say you should try
copyProperties with isWritable.

Hans

-----Original Message-----
From: Simon Kitching [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, September 21, 2004 12:06 AM
To: Jakarta Commons Developers List
Subject: Re: cvs
commit:jakarta-commons/digester/src/java/org/apache/commons/digesterSetPrope
rtiesRule.java

On Tue, 2004-09-21 at 09:59, [EMAIL PROTECTED] wrote:
> rdonkin     2004/09/20 14:59:23
> 
>   Modified:    digester build.xml
>                digester/src/java/org/apache/commons/digester
>                         SetPropertiesRule.java
>   Log:
>   Allows exception throwing for mismatches to be switch on. Patch
contributed by Gabriele Carcassi.

I'm worried about this patch.

The existing code to actually do the assignment to properties calls
BeanUtils.populate(...) which calls BeanUtilsBean.populate(...) which
calls BeanUtilsBean.setProperty(...).

This patch however uses PropertyUtils.isWriteable to check for the
existence of the property.

The two code paths are completely different, and I am concerned that
they may consider different things to be valid properties. 

I would prefer to see either:
(a) BeanUtils.populate modified to optionally throw an exception if a
matching property can't be found, or
(b) SetPropertiesRule be modified to use PropertyUtils methods to do the
property setting rather than BeanUtils.populate.

The latter is probably too risky a change to make; too much chance of
breaking existing digester users like Struts.

While I very much like this new feature, I am not convinced using
PropertyUtils methods to implement it is safe.

Regards,

Simon


---------------------------------------------------------------------
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]

Reply via email to