struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael Jouravlev <>
Subject Re: [FORMDEF] Resetting booleans for session-scoped dynaforms
Date Wed, 12 Oct 2005 18:35:10 GMT
On 10/12/05, Hubert Rabago <> wrote:
> I'm not sure we're understanding each other about this request type.
> When a form is submitted, here's what happens:
> * Struts receives a request for an action
> * Struts sees that a form was configured for the mapping, so it calls
> retrieves the form (if it can find it) or creates a new one
> [processActionForm()]
> * In [processPopulate()], Struts resets the form fields then populates
> them from request parameters

Struts calls ActionForm.reset() *before* populating the fields from
request. reset() receives HttpServletRequest, so I can check request
type *before* resetting (or setting up, if you prefer) the form and
*before* the population occurs.

For example, this is what I do in SubscriptionForm in my version of MailReader:

// Subcription form is submitted with POST method,
// clear checkbox before populating it from request
if ("POST".equalsIgnoreCase(request.getMethod())) {

I do this, because I use the same form to show JSP page via redirect.
When redirected request comes, it has GET type (302 by convention and
303 by HTTP 1.1 spec), so I can filter it out and do not reinitialize
my session-scoped form.

If I used a dynaform for my subcription form, I would have liked to
define this behavior in the config, like:


> If you're prepopulating your form, none of this matters, since either
> (1) you'll override the effect of reset() anyway inside your action,
> or (2) you'll be creating your form bean from scratch.

Exactly, I am overriding reset() and I want to do this only in certain
conditions, usually when request has POST type.

Calling reset() on the form and populating it are two different
processes. For a dynaform default values are used instead of calling
reset(), right? So I want these values to be used *only* when request
has a certain type.

Seems that these changes can be implemented only by redefining request
processor. I wish it could make it in 1.3.


> On 10/12/05, Michael Jouravlev <> wrote:
> > That would be great, but please don't forget the request type. Usually
> > I need to do this for POST requests only, this separation by type is
> > really important to me. So instead of reset="true" I would rather
> > have:
> >
> > <form-property
> >   name="someFlag"
> >   type="java.lang.String"
> >   initial="true"
> >   reset="POST"/>
> >
> > where "reset" can be:
> >
> > * "true" or "ALL" to reset for any request type;
> > * "POST" or "GET" or "POST, GET" or "POST, GET, HEAD"
> >   or whatever other possible types, can be comma-separated,
> >   to reset for specific request types only.

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

View raw message