On Fri, 14 Feb 2003, Jim Krygowski wrote:

> Date: Fri, 14 Feb 2003 13:50:33 -0500
> From: Jim Krygowski <[EMAIL PROTECTED]>
> Reply-To: Struts Users Mailing List <[EMAIL PROTECTED]>
> To: Struts Users Mailing List <[EMAIL PROTECTED]>
> Subject: [Q] Is Struts use  of BeanUtils and PropertyUtils inconsistent?
>
> Hi-
>
> I noticed that when a request is processed by RequestUtils and its values
> are copied into an ActionForm, Struts uses the BeanUtils class. Deep inside
> BeanUtils, the method for copying (getSimpleProperty) uses ConvertUtils's
> convert() method  before returning the requested value.
>
> However, all the tags in Struts use RequestUtils.lookup, which in turn uses
> PropertyUtils and the getSimpleProperty method on PropertyUtils doesn't use
> the converter utilities.
>
> This seems somewhat inconsistent.
>
> I know Craig and a few others on the list advocate creating parallel
> String-only value objects and then manually converting (using BeanUtils) in
> the action.  Their reasons are valid, but add a lot of extra work especially
> if you're rendering non-trivial object graphs, (n deep X n wide).  My app
> has about 70 value objects right now and I'd hate to create and maintain 70
> parallel string-only value objects.
>
> Beyond even that issue, what's the point of doing a conversion inbound if
> you're only ever going to deal with Strings?
>

The conversions on form submit are required because HTTP request
parameters are all strings.  Struts does not have any innate knowledge of
your model tier's requirements, and in particular does not know what the
caller of RequestUtils.lookup() is going to do with the data that is
returned.

> My ideal would be to allow for conversion outbound.  This would require
> switching from PropertyUtils to BeanUtils in the RequestUtil.lookup.  Maybe
> this is a good feature for Struts 1.1b4?  What do you think?
>

Doing that by itself would break a huge number of apps that depend on
RequestUtils.lookup() working the way it does.

It sounds like you'd be better off creating a customized version of the
<bean:write> tag that does the conversion for you.  That wouldn't be
particularly difficult to implement.

Craig

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to