aspose file tools*
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
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Multiple forms with one action class" Watch "Multiple forms with one action class" New topic
Author

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 ?

Thanks


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.


Merrill
Consultant, Sima Solutions
 
Don't get me started about those stupid light bulbs.
 
subject: Multiple forms with one action class