aspose file tools*
The moose likes Struts and the fly likes Doubt regarding action class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Doubt regarding action class" Watch "Doubt regarding action class" New topic
Author

Doubt regarding action class

san geetha
Ranch Hand

Joined: Sep 07, 2004
Posts: 44
Iam new to struts framework, need to clarify few things before i start off with my project. When a new java class is written by extending the action class, we need to override the execute() method. In my scenario there are different segments in my execute method, that are executed in a conditional loop.
So is it advisable to have private methods in the java class file that i write instead of writing a seperate class file for these(cos my project is very small, consists of 4 screens)
What is the general way adopted while using struts framework?

Thanks,
Sangeeta
John Smith
Ranch Hand

Joined: Sep 02, 2004
Posts: 61
It's good practice to seperate out your action classes, it's not a lot of work really. Generally you should call each action twice, once for initialisation and once to actually do the action and select an appropriate forward. the easiest way to do this is using the parameter attribute in your action mappings (struts-config.xml). This is assuming your "screens" are jsp forms, if not you may want to drop the initialisation calls, hope this makes helps
san geetha
Ranch Hand

Joined: Sep 07, 2004
Posts: 44
Thanks, that did help me decide.

Cud u explain this:

the easiest way to do this is using the parameter attribute in your action mappings (struts-config.xml).


jus a sample of xml file wud do.

Regards,
Sangeeta
John Smith
Ranch Hand

Joined: Sep 02, 2004
Posts: 61
Like such, these actions both use the same class, in the execute method I use an if statement on mapping.getParameter() to see wich action is being called

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Doubt regarding action class