File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes Struts Form Submission. Multiple Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts Form Submission. Multiple "Insert" Statements." Watch "Struts Form Submission. Multiple "Insert" Statements." New topic

Struts Form Submission. Multiple "Insert" Statements.

Mervin Chan

Joined: Dec 03, 2004
Posts: 24
I have a problem with struts form-submission.

I want to insert entries to a DB using a form. The form looks something like this.

1. Entry 1 [submit]
2. Entry 2 [submit]

The number of rows is dynamic.Every row has a "Submit" button. When the user hits the button, the DB is updated with the row's data. This is done via an ActionForm, which will pass the parameters to the db via a single SQL insert statement. All this works (for a single row "insert")

What I want to achieve is for the user to amend the entries, then hit a single submit button, to insert all the rows' data in one go, like so

1. Entry 1
2. Entry 2

[Submit All]

How can i achieve this? Is there a way to loop through the entries, doing the "insert" statement multiple times (depending on the number of rows on my table?). The "Insert" statement works for only one row. I do not wish to change the insert statement. The main problem is that the number of rows is not-fixed.

If anyone can point to me a similar solution online, it'll be mightly fine. Thanks!
Nathan Pruett

Joined: Oct 18, 2000
Posts: 4121

Moving to the Struts forum...

Write once, run anywhere, because there's nowhere to hide! - /. A.C.
Marc Peabody
pie sneak

Joined: Feb 05, 2003
Posts: 4727


A good workman is known by his tools.
I agree. Here's the link:
subject: Struts Form Submission. Multiple "Insert" Statements.
It's not a secret anymore!