I've stumbled across a similar problem that I'm trying to find the
Struts solution for.

I have a form which allows users to add a dynamic amount of rows (via
a button that says "Add Row") and then submit the form with as little
or many rows as they wish.  Can a form bean be setup using collections
instead of other object types?  What is the proper way to handle a
dynamic amount of the same data coming in to a Action?

~ Andrew Tomaka

On 7/18/05, Rick Reumann <[EMAIL PROTECTED]> wrote:
> Mike Elliott wrote the following on 7/18/2005 10:55 AM:
> 
> > I've been beating my head against this all weekend to no avail.  I
> > understand how to do this in session scope, but don't know if it's
> > even possible in request scope.
> >
> > As I understand things (which may be wrong), when the form is
> > submitted (in request scope) a new form bean is created and populated
> > with the values in the collection from the HTML form.  But, of course,
> > a newly created form won't know how many elements are in the form so
> > it can't pre-populate the collection with beans to be filled in.
> > Right?
> 
> I'm still not totally clear where the problem is, since I'm not sure
> what Session has to do with the initial setup of the form. It might help
> if you let us know what the exact problem is when using request scope...
> 
> 1) A problem when you submit the form and getting 'index' problems
> showing up in the logs?
> 
> 2) Is it making sure the nested structure is still there when validation
> fails?
> 
> I'm confused because you mention "But, of course, a newly created form
> won't know how many elements are in the form so it can't pre-populate
> the collection with beans to be filled in." This statement confused me
> because you seem to be implying it works when it's in Session which
> doesn't make sense since even with a Session scoped form you still need
> to some initial population somewhere.
> 
> Typically I feel you should always go to some sort of "setUp" action or
> dispatch method BEFORE you ever forward to a form. Initially you can
> often skip this step but later on there will be something you want to
> 'do' before you get to the form anyway so I find it good practice to go
> to a 'set up' first.
> 
> For the two problems listed above the link Naill posted is good
> http://wiki.apache.org/struts/StrutsCatalogLazyList (and I just recently
> added to that link the way I like to do it).
> 
> Let us know if you can't get it to work. I have to use Nested stuff all
> the time, so I'll be able to help.
> 
> --
> Rick
> 
> ---------------------------------------------------------------------
> 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