wood burning stoves 2.0*
The moose likes Struts and the fly likes One Action Class for Two Forms in Struts Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "One Action Class for Two Forms in Struts" Watch "One Action Class for Two Forms in Struts" New topic
Author

One Action Class for Two Forms in Struts

Vishnu Vardhan
Greenhorn

Joined: Nov 05, 2003
Posts: 14
Can I have only one Action Class handling two forms in struts. If yes how could I do it?

Thanks
Vishnu
Jass Singh
Ranch Hand

Joined: Mar 30, 2006
Posts: 52
Originally posted by Vishnu Vardhan:
Can I have only one Action Class handling two forms in struts. If yes how could I do it?

Thanks
Vishnu


Why would you like to do that ?

As per strtus standard and even otherwise as best pratice you should use only one Form in one Action class.

Technically speaking, you can manipulate that by having 2 entries of <action in struts-config.xml and specify same action class but different form for each <action. In execute() of Action, first check type of Form using instanceof and then proceed accordingly. But you should avoid doing that.

Regards,
Jass
Rohit Dhodapkar
Ranch Hand

Joined: Apr 27, 2006
Posts: 38
You can use to forms for the same action even you are using Dispatch Action or LookUp Dispatch Action..
Vishnu Vardhan
Greenhorn

Joined: Nov 05, 2003
Posts: 14
Thanks All

Just wanted to be sure of it as I was asked in an interview about it.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: One Action Class for Two Forms in Struts
 
Similar Threads
Struts 1: Selective Validation of Form
using a pojo model in a struts app
a single action a struts application
two actionForms for one action class?
Getting results to the forwarded page