struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rick Reumann <strut...@reumann.net>
Subject Re: Multiple ActionForms per ActionMapping
Date Fri, 18 Mar 2005 15:32:35 GMT
Frank W. Zammetti wrote the following on 3/17/2005 10:23 PM:

> Certainly I can see the reasoning behind that, but I would have to 
> disagree.  What if down the road I need to use one of those screens 
> independant of that original flow?  Isn't it just added complexity to 
> have all the extra stuff in the ActionForm then?

Ok, then how about using separate ActionForms and after each submits 
copy the properties (BeanUtils) to a POJO that you are using in Session 
scope to hold the values you finally need. This way you have the 
flexible separate ActionForms but still have a Master record holding 
what you need along each step. (Heck, you could even take the lazy way 
out and make the master session object a Map so you wouldn't even have 
to care about creating the pojo ahead of time.. although I still prefer 
a nice POJO over a Map for stuff like this.)

> A good example is the application I was talking about itself... The six 
> screens are not simple in and of themselves, there is quite a bit of 
> complexity to the ActionForms for each, in terms of how many fields 
> there certainy.  If I combined them all it would be a very unwieldly 
> beast to maintain (I'd have to look, but I can imagine it being close to 
> 2,000 line of code without much trouble, perhaps more).

Well, remember those 2000 lines of code are simply getters and setters 
which are easily auto-generated. It's not really complex lines of code. 
Really you are only maintaining field names. I do see  your point though 
about how it's nice having the ActionForms separate for a more resuable 
approach. I'd opt for the option I mentioned above first, if you want to 
keep the forms all separate.

> In addition, how would you handle validation then?  The validate() 
> method is meant to apply to a single page (as is an ActionForm), 

Actually you can validate on an action mapping basis and not on the form 
name, so only the fields you are interested in for the action mapping 
get checked.


-- 
Rick

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Mime
View raw message