struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Kyle W. Cartmell" <>
Subject Re: validation breaks my form prepopulation
Date Wed, 03 May 2006 21:32:41 GMT
Thank you Michael. This is extremely descriptive, and I'm going to 
devote my nightly reading time to your article this evening. :)

What this tells me for right now is that this method of transferring 
data isn't really something I should be using. I'm going to put my 
temporary session object manager back into play.

Thank you again for all the help, and thank you everyone for your patience!

Michael Jouravlev wrote:
> On 5/3/06, Kyle W. Cartmell <> wrote:
>> I did some tinkering and found that even though my setup action is
>> indeed associated with a form bean, and my reset method is defined and
>> sets my values to null, when I return to an action from a validation
>> failure or forwarded from another action, the form that I originally
>> used to populate the data on that page is present and intact.
>> 1. Is it reasonable to simply make use of this mechanic to allow this
>> data to persist?
> How many forms do you have: one or two? If two, do they have
> properties with the same names? If I remember correctly, this should
> work somewhat like this:
> * You submit an HTML form to a submit action, well, actually to an
> action mapping
> * If actionform is defined for the mapping, it is initialized. That
> means, that if it has request scope, it is created. If it has session
> scope it is usually reused (this is not guaranteed, but I've yet to
> encounter the situation when session-scoped form was not reused).
> * reset() is called on form
> * form is populated from request parameters
> * if "validate" attribute of the action mapping is set to true,
> validate() is called
> * if validate() returns non-empty object and you have "input"
> attribute set, then control is forwarded to the location defined in
> the "input". (Hmm, what happens if you have validate="true" but do not
> have "input" attribute?) By the way, it is possible to redirect to
> "input" location instead of forwarding, but this is done globally for
> all mappings in the config file.
> * If you do a regular forward using "input" attribute, the
> request/response sequence has not been finished yet, so all objects
> that were created when you submitted the request, are still there,
> including request-scoped actionform and request object itself. So, if
> you forward to a regular JSP page, you can pull data from the
> actionform or from request object.
> * Now, the fun part. If you forward to a setup action, then Struts
> will look for an actionform associated with this mapping, and will
> call reset() on it, then it will try to populate it from the request
> object, then it will call validate() if you have validate="true". So,
> if you forward to a setup action and you have changed content of the
> actionform, you should either NOT associate a form with an action.
> Because otherwise your changes to actionform fields will be
> overwritted from the request object. Does it make sense? ;-)
>> 2. I find that I am shocked by some astounding discovery regarding
>> Struts functionallity, and I have gone through all of the documentation
>> on the website, can anyone direct me toward comprehensive (or as close
>> as possible) documentation of Struts internals in hopes that I can stop
>> posting silly questions here and not have to resort to reading source?
> I think that it all clears when you understand how scoped objects are
> managed, and how the request/response cycle works. The key here is
> that Struts runs its portion of request/response code whenever you
> call an action mapping, even if you make a server-side forward.
> I wrote a small article on that topic [1]. It is not perfect and,
> frankly, needs a rewrite (I introduced my own names to some of the
> action/form combinations), I would do some things differently. But
> some sections of it are still valuable. Take a look at "Two actions,
> one form" and "Two actions, two forms" sections. Currently I prefer to
> use only one actionform and two action classes (input and render) for
> one web resource.
> Oh yeah, and as the article says, use the same scope if you use the
> same form name :-) Otherwise you'll get some funny results.
> Michael.
> [1] 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

Kyle W. Cartmell
Sr. Software Developer
LAP Holdings, LLC dba First Finance
Phone: (480) 222-0050
Toll Free: (800) 355-3135

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