File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes Multiple forms with one action class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Multiple forms with one action class" Watch "Multiple forms with one action class" New topic

Multiple forms with one action class

Ambika Jain
Ranch Hand

Joined: Jan 27, 2005
Posts: 48
My application has 2 tabs and the user can add the details in both the tabs. But only when he clicks on "Save", which is in the first tab only, the info in both the tabs gets saved.
For such scenario is it a good idea to use 2 forms of the 2 tabs and one action class ?
Also does anyone has a sample program using multiple forms with one action class ?


Ambika Jain
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
While it's possible to have a single Action process two different ActionForms, it's not a clean solution, and I think it's better not to do it. You end up with a lot of if/else logic in your code, which can be cluttered and confusing.

If you do use the same action for the two different function, I'd suggest extending DispatchAction. This link explains more about how to do this.

Consultant, Sima Solutions
I agree. Here's the link:
subject: Multiple forms with one action class
It's not a secret anymore!