This approach simplifies using session-scoped ActionForms to implement wizards. You can just keep submitting back to the same ActionForm, adding properties as you go. The Struts Validator also supports this idea with its page number approach.
As mentioned, many developers prefer to use request-based ActionForms to alleviate problems with session management. With 20:20 hindsight, this probably should have been the default. However, there is an alternate ActionMapping you can specify that defaults to request-scope, so that you can still have it either way.
The reset method is not so much there so you can recycle ActionForms. In fact, I often advise people not to reset ordinary properties, since it most cases it's a waste of time. The real reason for reset is to handle checkboxes on session-scoped forms. Given the way checkboxes works, unless you reset a checkbox on a session-scope form, you can't turn it back off. There are many other things I use reset for, but blindly setting properties to their defaults is not one of them.
-Ted.
Radek Wisniewski wrote:
Could somebody explain, why we actually need ActionForms recycling?
I see one cause: it is "probably" quicker as instantiation of new one.
But i see some drawbacks:
1) To use it properly, you must implement reset() method. But using reset() method is error prone, you can easy add new property without adding resetting of this one.
2) If you reset all properties, you can not use such ActionForm for collecting data among more HTML Forms - it is not easy to undestand for new users, for me it's like a trap in this whole design.
3) Sometimes you need prepare (set) some values. The best choice is to put such code in logic tier - Action befor forwarding to view. But in this case reset() may delete those values if you use redirections.
4) Struts code without recycling could be easier.
5) I spouse, reset() is in most cases not very much quicker as making new instance. In any case, instantiatation of new form occurs relative seldom.
I think, we schould remove recycling of ActionForms and reset() schould be deprecated.
-- Ted Husted, Junit in Action - <http://www.manning.com/massol/>, Struts in Action - <http://husted.com/struts/book.html>, JSP Site Design - <http://www.amazon.com/exec/obidos/ISBN=1861005512>.
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]