hi craig

unfortunately (or not) SetPropertiesRules has used beanutils.properties since you imported it from struts. i'd be very reluctant to change it for fear of breaking backwards compatibility.

the information from hans is quite useful since jelly has recently revised the original choice (to use beanutils.properties) and there don't seem to be any ill effects. maybe it we could factor out the actual property setting leaving the existing situation as default (for backwards compatibility).

- robert

On 22 Sep 2004, at 21:37, Craig McClanahan wrote:

In case it is not obvious enough from the blatant comments in the
Javadocs, BeanUtils.populate() is ABSOLUTELY, POSITIVELY not
appropriate for general XML processing.  It is finely tuned to dealing
with typical issues you see in processing request parameters in a web
application (which is where this code was originally used in Struts).

If you need property copying with conversion, use
BeanUtils.copyProperties().  If you don't need the conversions,
PropertyUtils.copyProperties() will run substantially faster.

Craig McClanahan


On Tue, 21 Sep 2004 23:58:34 -0400, Hans Gilde <[EMAIL PROTECTED]> wrote:
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]



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