struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Craig McClanahan <>
Subject Re: Eliminate Setup Actions
Date Sat, 05 Mar 2005 23:25:07 GMT
On Sat, 05 Mar 2005 17:56:40 -0500, Frank W. Zammetti
<> wrote:

> Then again, I know *someone* is going to point out that Shale (or I
> guess JSF generically?) already has this notion ingrained in it.

But of course!  :-)

In Shale, a ViewController bean (pretty much the equivalent of
ActionForm+Action) has callback methods that the framework calls for
- init() -- called if this page is going to either process a postback
  or be rendered
- preprocess() - called if we are about to process a postback
  (form submit) for the corresponding page
- prerender() - called if we are about to be rendered
- destroy() - called if init() was ever called

To the original question about getting rid of the setup action, the
Shale approach is to put that kind of setup stuff (populating dropdown
list options, etc.) in the prerender() method, which will be called
*only* if we are the page that is going to be rendered -- thus
avoiding needless work if you navigated somewhere else instead.

For Struts 1.x, the "setup method" or "setup helper class" idea seems
reasonable, unless you are using Tiles.  In that case, use a Tiles
Controller, which is almost the same thing as the Shale prerender()
method -- it is called just before that tile is rendered, and is
(again) the right place for this sort of setup behavior.


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message