aspose file tools*
The moose likes Struts and the fly likes multiple action forms in one action class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "multiple action forms in one action class" Watch "multiple action forms in one action class" New topic
Author

multiple action forms in one action class

anvi kon
Ranch Hand

Joined: Jan 08, 2010
Posts: 133
Hi,

Can anyone tell me, Is it possible to set multiple action forms in one action class?

Here is the case.


thanks


Tom Rispoli
Ranch Hand

Joined: Aug 29, 2008
Posts: 349
I would think that would work, as long as firstForm1 and firstForm2 are either the class you specified as the form class for the action or they are super classes of it. Also, capitalizing your class names, and camel casing your object names may make your code a little easier to read.
anvi kon
Ranch Hand

Joined: Jan 08, 2010
Posts: 133
can you please explain with more detail using my example?


thanks
Tom Rispoli
Ranch Hand

Joined: Aug 29, 2008
Posts: 349
Well first off I made an assumption here, and maybe its an incorrect one, that you are always calling this action class using the same action. To tell you more I'd need to see your struts-config.xml entries for the actions that are going to go to this Action class, what classes you are using for the form beans for each action, and how those form beans fit into your class hierarchy with firstForm1 and firstForm2.
Shankar Tanikella
Ranch Hand

Joined: Jan 30, 2011
Posts: 329

Always, better to use instanceof in your conditions

This can be achieved if you have same action class mapped with different action paths and you submit different forms accordingly from several JSPs

i.e. Say you have configured Action1 in struts-config with Form1 (used in JSP1), Form2 (used in JSP2), Form3 (used in JSP3). If you are submitting form JSP1 then you would get the instance of Form1 in the Action1's method. Similarly JSP 2 & 3

I prefer not to have such scenarios since for developing it may be easier but for maintenance?? Never


Have Fun with Java
little,little.. little by little makes a lot..
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: multiple action forms in one action class