struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael Jouravlev <>
Subject Re: help with a newbie topic-prepopulating a form
Date Wed, 06 Jul 2005 00:35:15 GMT
On 7/5/05, Tony Dahbura <> wrote:
> Team:
> I am trying to pre-populate a form before letting the user enter/correct
> data in it.
> The only way I have seen to do this is to actually do this prefilling
> fields in the reset method of the actionform.  I am not sure this is the
> place to do this.....
> For instance I have a form that lets user edit their profile and I want
> to pre-populate with their name and phone number etc...Should I do all
> this in the form's actionForm reset method or where?

Hey boss, you did not give your team enough details on your
configuration, so I can just assume that you are sending request to
action mapping, and then display JSP page using values from an

So, here is the standard sequence: ActionForm.reset() / populate
ActionForm from request / ActionForm.validate() / Action.execute() if
no errors returned from ActionForm.validate() / render JSP.

So, if you are expecting request data, you have to decide what takes
precedence: request data or your data. If request data wins, then you
initialize your actionform in reset(), and it will be updated with
request values if any when actionform is populated with request
values. If default values win, than you initialize your actionform in
validate() (if you do not define custom action class) or in action
class. Catch: if you action form has request scope, then reset() may
(will?) not be called, so I would call reset() manually from the

Another catch: if you use the same action both to initialize your form
and to accept user input, than you need to distinguish somehow between
these two modes: when you are presenting the form for the first time,
and when you are accepting input and (maybe) re-rendering the form
with current data and (possibly) with error messages. Hmm, I guess
putting default values in reset() seems more logical.


Dialogs for Struts,

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

View raw message