• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

One Action Class for Two Forms in Struts

 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks All

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