Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

One Action Class for Two Forms in Struts

 
Vishnu Vardhan
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can use to forms for the same action even you are using Dispatch Action or LookUp Dispatch Action..
 
Vishnu Vardhan
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks All

Just wanted to be sure of it as I was asked in an interview about it.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic