struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Craig R. McClanahan" <Craig.McClana...@eng.sun.com>
Subject Re: Request for new functionality..
Date Sat, 24 Jun 2000 15:58:28 GMT
Kevin Duffey wrote:

> Hi all,
>
> Mostly to Craig, but would like to see some comments too.
>
> I find myself putting the same bit of code in every Actin perform() method.
> That is, to allow one Action to handle multiple forms, using the "command"
> pattern, in every Action I am doing something like this:
>

My personal preference is to be pretty cautious about adding global features
(and especially where it breaks the code that is starting to be built on Struts)
unless it is really something that everyone needs -- like the incompatible
change we did to return ActionForward instead of void from the perform() method.

One easy way to deal with this pattern in the current architecture is to extend
the ActionMapping classes you use with a "command" property.  Even though you
might be calling the same Action class ultimately, you would have a separate
ActionMapping for each of them (so you can change your mind later about
combining versus not combining them and not have to change the user interface).

The way that I dealt with this concept in the sample application was a hidden
"action" field in the input form (and the corresponding form bean so that it
gets populated automatically -- and you can even validate it!) so that I can
access it like any other bean property.  That way, you can use the "command"
pattern where you need it, and not where you don't.

Craig McClanahan



Mime
View raw message