Schaub, Stephen wrote:
What I'm wanting is an explanation of why I should keep the ActionForm class _separate_ from the Action class. It seems to me that this unnecessarily complicates the application design.
When a Struts-based app is "properly" architected, the Actions are nothing more than traffic cops... they move data sent from the client along to some "business delegate" where the real work of the application happens. That is their only purpose in life, theoretically.
The design that many people follow is that an ActionForm receives input from the client. The Action receives the form and uses BeanUtils (or similar) to copy the properties of the ActionForm into some other type of bean (DTO) that the business delegate knows how to handle. This is generally done with a single line of code (the copy I mean). Then the appropriate delgate is called, passed that bean, does its thing, and returns the bean (or a different one in some cases). The Action then copies that bean into the ActionForm, again with a single line of code, and forwards as appropriate. There might be some branching based on exceptions the delegate may throw, but in general this is how it flows.
So we're talking about three lines of code per Action, in an ideal situation. But that's not the pertinent fact... the pertinent fact is that the Action doesn't know anything about what actually is in the ActionForm, and therefore what is in the view, nor does it know what the delegate does or anything about the bean it uses, or in other words, the model.
So, let's imagine a situation where you want to add some fields that a user can enter on a given screen. No problem... you alter only your ActionForm (or just struts-config if your using DynaActionForm), and presumably the bean that gets passed to the delagate class as well. But the important point is that the Action is unchanged because it's only playing its role as a traffic cop and nothing else.
By combining Actions and ActionForms, you are breaking the separation. There *IS* clearly benefit to doing so... cutting down class count is something I'm always in favor of, so long as line count doesn't increase as a result. But is it worth it?
Clearly some now believe it is... as I understand it, that's one of the important concepts in JSF and ASP.Net, among others.
I wonder, would you think there is benefit to combining the two over a declarative approach like DynaActionForm? Using them you cut the class count down similarly, and in fact *REDUCE* overall line count as well, and you gain a declarative approach to things, which is definitely nice (I seem to remember that's how JSF approaches things, but it has been a while since I looked, my memory may be fooling me).
-- Frank W. Zammetti Founder and Chief Software Architect Omnytex Technologies http://www.omnytex.com --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]