Eric wrote:

> Sorry to post a similar question many times, but I'm striving to get
> an answer before the prototype of my project is due.
>

Sorry for not being able to give a comprehensive answer earlier ... I've
had more emergencies this week than I care to think about :-(.

>
> I'm looking for a way to deal with properties that correspond to form
> parameters such as Zoo1Animal1, Zoo1Animal2, Zoo2Animal1, etc.  I
> would like them represented as two arrays in two seperate beans (a
> Zoo array of AnimalForm objects and an Animal array of Strings in the
> AnimalForm bean).  This seems like something that could be used by a
> lot of complex input forms (especially ones that strive to keep inputs
> on one page).
>

I am still not sure that I understand the data model you are trying to
achieve.  Could you sketch out a few simple class and method signatures
that illustrate the pattern?

>
> My question is, why does BeanUtils.populate not use
> PropertyUtils.setProperty?  It seems like PropertyUtils.setProperty
> would do exactly what I want...is it used anywhere?  Is there some tag
> that corresponds to it?
>

PropertyUtils.setProperty does not do any type conversions -- it assumes
that your arguments are compatible and will throw exceptions if not.
BeanUtils.populate knows that the input values are strings, so it looks at
what the data type of the underlying property is and tries to do the right
thing.  (In the future, it will also respect the existence of
PropertyEditor classes if you have them for the data types used by your
beans).

If you want to populate things yourself with PropertyUtils.setProperty,
this should be possible -- you have access to all of the incoming
information in the request.  But you will need to be responsible for
converting from Strings (the way you receive all request parameters) to
the corresponding data types.

>
> Also, is what I'm considering reasonable?  Has anyone dealt with
> issues like this before?  Is it possible for me to modify
> BeanUtils.populate so that it uses PropertyUtils.setProperty and thus
> provides the functionality I desire?  Are there some inherant problems
> with this that I'm not seeing?
>
> thanx,
> eric.

Craig McClanahan


Reply via email to