struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Michael Gagnon" <mgag...@genome.med.harvard.edu>
Subject Advantage of prepare()?
Date Wed, 16 Apr 2008 13:22:03 GMT
I've been working with struts2 for about 2 months and so far I've been using
the preparable interface to populate any data the resulting page wants to
display. I've used the execute method to do non-visible work and determine a
result (which controls flow).

 

I'm wondering if this is the intended pattern. If so (and even if not), why?
The only intended benefit I see to using prepare at all is if you somehow
want to use one action in two different contexts - one which uses the
preparable interceptor and one which doesn't. If this was ever the case, I'd
argue two different actions should exist. If there's some common
functionality needed it should be in a superclass and the subclasses should
call into it in the execute method. So given the only appropriate scenario I
can think of off the top of my head, its use looks like an anti-pattern to
me.

 

 

I see prepare being used in the way I'm using it in many tutorials but I
haven't found any articles explaining any particular reason why. I'm hoping
maybe somebody can shed some light on this. should I bother using prepare at
all? Why?


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message