You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Phase Web and Multimedia <ma...@phase.ws> on 2002/09/13 20:01:14 UTC

Nested Vector Property Population

I am trying to use the nested tags to display and populate formbean and bean
information.

For the sake of a simple example here is my issue.

I have a ParentBean, ChildBean and CandyBean

The Parent Bean contains a List of ChildBeans
Likewise the ChildBean has a list of CandyBeans

So a ParentBean has a getChildBean which returns a Vector of ChildBeans and
a setChildBean that allows a Vector of ChildBeans to be set. I also have an
addChild method which receives a ChildBean object and adds it to the
ChildBean Vector.

The same would go for the ChildBean and it's candy.

When I populate the beans initially and pass them to the nested tags...
everything works fine (cuz I am populating the form by accessing the proper
add, set, get.

When I pass those form values back to the the ActionForm and the ActionForm
attempts to populate it's values i get an ArrayOutOfBoundException and it is
being thrown by the BeanUtils class.

I assume this is due to the BeanUtils trying to instantiate a Vector from
the setChildBean and it expects to have a Vector being passed to it instead
it receives a String array when struts attempts to populate the ActionForm.

I cannot know ahead of time how many Children the parent will have and
neither can i know how much candy each child will have.

Also, in my ActionForm I am merely placing a getter and setter for my
ParentBean so that i am using the ActionForm merely as a transport for
"already existing" beans to be used and populated. At least this is my
ideal. It would reduce the amount of ActionFrom coding i have to do. (I
already know about DynaActionForm).

In the nested bean examples i see that there is initialization and parameter
passing going on where the ActionForm is being tied to each Bean (model)
class. This seems to me to be innappropriate. Tying the ActionForm directly
to the model. tsk tsk! :-)

My question ultimately is:

Is it possible for Struts to populate Lists of Beans with other Beans from
form input or is struts only able to use Object[] arrays and Primitive
Arrays like String[]? If the latter is true. How do I go about fortelling
how much space i need to allocate in my arrays?

Brandon Goodin
Phase Web and Multimedia
P (406) 862-2245
F (406) 862-0354
mail@phase.ws
http://www.phase.ws



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>