I was talking about populating the form with information from the database
so the user can update the data.  What you are saying is that if you did
this work upfront and set the parameters with values for the field, it would
populate the form bean automatically if the names match.

What I have been doing is to use a form and an action, but two action
mappings for this type of thing.  The first action mapping has a parameter
of "initialize" and I go and get the data and put it on the form.  The
second action mapping has a paramater called "update" and I take the data
from the form, using the form bean and update the database.  Am I missing
something?

Mike

-----Original Message-----
From: Keith Bacon [mailto:[EMAIL PROTECTED]]
Sent: Thursday, January 10, 2002 10:11 AM
To: Struts Users Mailing List
Subject: RE: Populating a Form with values


I think you've missed the point of form beans.
On submission of an html form struts looks at the request parameters. If it
can find a matching
set method in the form bean it calls it. ie. the form parms are copied into
the form bean.

When you forward to a jsp with a form struts calls the get methods of the
form bean to populate
the the matching form fields (that have been defined with struts tags).

You action class can deal with the form variables by calling the same
get/set methods of the form
bean. This saves doing qqq = request.getParameter("qqq"); & testing for
nulls etc.

That's the whole point of form beans - to manage form fields.

To get readonly data onto your jsp your action class should place it in the
request where the jsp
can get at it easily.

Keith.





--- "Witt, Mike (OH35)" <[EMAIL PROTECTED]> wrote:
> I'm new to struts also, but the way I have been doing it is to set up an
> action and a form bean in the struts config.  The action code (or some
other
> bean that the action code uses) for getting the data from the database and
> populating the form using something like
> (MyForm)form.setField(theFieldData);
> 
> Hope this helps.
> 
> Mike
> 
> -----Original Message-----
> From: Daniel Jaffa [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, January 10, 2002 9:25 AM
> To: [EMAIL PROTECTED]
> Subject: Populating a Form with values
> 
> 
> I am new to struts so be nice (But i have worked with jsp for 2 years).  I

> have a form that i need to populate a form with values from the database.
I
> 
> pass the form a data_base id to the form but i now need the form to
populate
> 
> the formbean.  I know how to do this in jsp but i want to do the in the 
> struts way.
> 
> _________________________________________________________________
> MSN Photos is the easiest way to share and print your photos: 
> http://photos.msn.com/support/worldwide.aspx
> 
> 
> --
> To unsubscribe, e-mail:
> <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail:
> <mailto:[EMAIL PROTECTED]>
> 
> --
> To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>
> 


__________________________________________________
Do You Yahoo!?
Send FREE video emails in Yahoo! Mail!
http://promo.yahoo.com/videomail/

--
To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to