Depends. This topic is discussed heavily from time to time. The last tide was about a month ago :) Search archives.
Basically, if you need only to output your A, B, C entities, you do not need action forms. Just stick your object in the proper scope. If you need to input data into A, B, C or your A, B, C are interactive (that is you need to output them, to modify them, to validate and to redisplay them on error, and finally to store them back to hibernate) then I know two obvious choices. You must recall, that: * Struts automatically stores request values into action form when request hits the server. * Also, action form is a bean, accessible from JSP. Thus, action form can be used as a buffer for interactive I/O. * Struts uses setters and getters to access properties. * Struts does not try to set property, if request does not have corresponding value. * Simple redirect does not keep request values. * Another thing to know, is that action form can handle aggregated (aka nested) objects. The choices I know of: (1) Use action form as I/O buffer, business objects would contain only valid and persisted data. Copy data from action form to BO when you store data. (2) Use a separate instance(s) of business object(s) or DTO(s) as I/O buffer, and store all interactive data there, even invalid data. Valid data can be persisted to database or wherever. For (1) you would need to write a lot of setters/getters, but on the plus side is that you do not need to call your business layer unless all values are valid. You can check validity in validate() method. On the other hand, if you already have validation functionality on business layer, this does not look good. For (2) You can aggregate your BOs in the action form. In this case action form should have session scope. Struts would populate your BOs as nested properties of action form. Less bloat in action form, but your BOs need to accept strings, to validate input, and to store whatever was set, even invalid data. Are you going to handle Refresh button and double submits? After I typed that huge email, I think I am entitled to a small plug :) Take a look at DialogAction at http://struts.sourceforge.net/strutsdialogs/dialogaction.html , maybe you could use some its ideas. Michael. On 6/14/05, Ovidiu EFTIMIE <[EMAIL PROTECTED]> wrote: > Hi, > I've recently started working on a project that uses Struts 1.2 and > Hibernate - and I'm in the dev team. Nothing unusual here. > The project architecture is made in such way that ActionForms are an > almost 1-1 mirror with the the Hibernate mapped entities. > For example : if I have an entity A that contains an entity B and a > list of etities C, in the corresponding forms I'll have Aform > containing Bform and a List of CForm objects. > > What I would like to know if anyone used the ActionForms in such a way > , or if this is considered to be a best practice. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]