struts-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ted Husted <>
Subject Re: ActionForm initialization
Date Tue, 02 Jul 2002 15:06:25 GMT
The general workflow is for all requests to go through an Action before
they go out to a JavaServer Page. Any objects that need to be
initialized should be initialized by the Action, and then forwarded out
to the page. If the ActionForm is part of the Action's mapping, then the
controller will instantiate it for you, place it in the request, and
also pass a reference in the method signature. The <html:form> tag will,
as a last resort, initialize and ActionForm if none is present in the
request, but most developers do not depend on that behaviour. 

ActionForms are white-box objects and meant to be subclassed. If you
would like to subclass yours to include a value object, some developers
do find that convenient. 

An underlying differnce between Swing and web applications is that all
of the form properties are updated at once in a non-modal state, and not
one-by-one in a modal state. So, your form's do not have the option of
rejecting input as it entered. The ActionForm is needed to receive the
input, examine it, and then determine if it is to be accepted. Most GUI
components have a hidden String buffer that does that sort of thing.
HTML/HTTP does not provide that sort of thing, so we use ActionForms to
provide our own. The Actions are the place where the buffered data is
taken from the buffers (the Actionforms) and applied to the value object
of your choice. 

You can tie the value object to the ActionForm, and just have the Action
call a "getInfo()" method or whatever once the data is validated. Or,
following the principal of lazy initialization, you can validate the
input first, and the instanitate the value object when you ready for it
to be used. 

The ActionForm can be subclassed in any way that suits your application
design, so the choice is yours =:0)

-- Ted Husted, Husted dot Com, Fairport NY US
-- Java Web Development with Struts
-- Tel: +1 585 737-3463
-- Web: wrote:
> I've read several topics debating this. These discussiosn leave the issue ambiguous.
I've written couple of notes in "struts-user," but received no response. This makes me think
it's an architectural issue, perhaps best addressed in this forum.
> What I want to be able to do is described in my topic:
> Having the ActionForm store a reference to a value object allows us to easily use the
Struts framework to update values, but still provides an intermediate set of values (that
can be in an invalid state). Our Action classes (or whatever logic we'd like) controls when
to try to apply this data to the model.
> (Updating this value-object, or some model directly, is what Swing does. In fact, it's
the *point* of Swing's approach to models -- earlier GUI component designs had data stored
with each component. This data had to explicitly applited to some model. This was problematic
in terms of syncing data across viewing components, hence the Swing approach.)
> Does the architecture have a standard way of handling this, or not? (Again -- the key
question is how/where to initialize the ActionForm property referencing the value object.)
> --
> Posted via
> --
> To unsubscribe, e-mail:   <>
> For additional commands, e-mail: <>

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

View raw message