By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,538 Members | 1,130 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,538 IT Pros & Developers. It's quick & easy.

Struts - Submitting a Variable Number of "records" under one form.

P: n/a

This title is a little ambiguous but this is an interesting puzzle.

Lets's say we have a JSP page with a form. The ActionForm associated
with this form has, say, 4 String properities. Very simple. Remember,
we only have one form.

Now let's say each the 4 String properties together comprise a record
and the user is able to view and edit a variable number of records at
the same time. Depending on how many "records" there are in our
database, the JSP should display them all. The user can edit any data
they wish and submit the form to submit all of the records back to

So each property will need a <html:text> element for every record

Submitting one record would be straightforward. This is a normal
Struts scenairo. There will be one ActionForm with one value for each
of the 4 properties.

How about two records? Do we need two instances of the ActionForm
somehow? Or should the ActionForm associated with the form contain
Lists of these properties so that the size of each List reflects the
number of records to be displayed? Both of these approaches violate
the set-up of the framework. Only one ActionForm can be submitted
with each form but ActionForms cannot contain collections as

Wait, maybe we should break out each record into its own form! This
is sort of unfriendly for our users. Ideally, the user should be able
to edit (or even add) records and then just click one button to submit
all the changes.

I present this problem knowing full well that there must be a smooth
solution. Also, I am presenting what I know about Struts. So let me
know about faulty reasoning or logic. What have you done in this

Duke Hamacher
Jul 17 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.