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?
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
Joined: Sep 07, 2004
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.
Joined: Sep 02, 2004
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