This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Struts and the fly likes Putting my head into Strurts.... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Putting my head into Strurts...." Watch "Putting my head into Strurts...." New topic
Author

Putting my head into Strurts....

Julie Desuza
Greenhorn

Joined: Sep 06, 2004
Posts: 3
Just to confirm from experts. I am new in Struts environment and trying to put my head into it. I assume the following.

If I have 5 input JSP forms then �

I can have 5 separate Action Form Beans (one for each form), having only getXXX() and setXXX() without implementing any business logic.

OR

I can have only single Action Form Bean for all the 5 forms.

If my one form contains 3 different actions such as Send / Cancel / Reset then I will have three action classes (One action class per each action). Every action class will have an execute() , which will return me an object of ActionForward class.

Am I going in the direction ?

- Julie
Leandro Melo
Ranch Hand

Joined: Mar 27, 2004
Posts: 401
Originally posted by Julie Desuza:

I can have 5 separate Action Form Beans (one for each form), having only getXXX() and setXXX() without implementing any business logic.

Yes, you can have 5 diferent form beans, one per page, but i didn`t understand about what you said with "business logic". The only place you should implement some weak business logic in Action Forms is in the validate method.

Originally posted by Julie Desuza:

I can have only single Action Form Bean for all the 5 forms.

Wel, if your 5 forms contains the same field, you can map the 5 jsps to use the same form (in struts-config.xml).

Originally posted by Julie Desuza:
If my one form contains 3 different actions such as Send / Cancel / Reset then I will have three action classes (One action class per each action). Every action class will have an execute() , which will return me an object of ActionForward class.


This is not a good strategies. It`s usual to build actions that encapsulates some basic functionality, for example, the CURD (create, update, retrieve and delete) operations of some specific funcionality should be placed in the same Action using methods name create, update, retrieve and delet. The same applies to the example you mentioned, Send, Cancel, and Reset should be placed in the same action because they actually deal with the same data.
The best way to do that is using DispatchAction and LookupDispatchAction with any other needs your application requires. An example of LookupDispatchAction follows
here
[ September 06, 2004: Message edited by: Leandro Melo ]

Leandro Melo
SCJP 1.4, SCWCD 1.4
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Putting my head into Strurts....
 
Similar Threads
Multiple actionerror tags problem
Passing values from forms..
Validation for included forms.
Multiple ActionForms for DispatchAction
Struts-Config