On Mon, 29 Jul 2002, Dave Weis wrote:

> Date: Mon, 29 Jul 2002 11:53:40 -0500 (CDT)
> From: Dave Weis <[EMAIL PROTECTED]>
> Reply-To: Struts Users Mailing List <[EMAIL PROTECTED]>
> To: Struts Users Mailing List <[EMAIL PROTECTED]>
> Subject: Re: Prefilling ActionForm Data
>
>
> On Mon, 29 Jul 2002, David Graham wrote:
> > I'm pretty new to struts and have figured out how to do an "add" form  where
> > you start with an empty set of text boxes, fill them in, and when you submit
> > it puts the data into a database.
> > How do I setup an "edit" form where you get a url like
> > /updatePerson.jsp?id=61 where id is the person id from the database?
> > I need to query the database based on the id and prefill the text boxes.
>
> What I usually do is have an edit action and a save action. They both have
> the same form bean associated with them. In the edit action, you will have
> access to the form bean, so you can grab your data from the database and
> do something like:
>
> MyFormBean fb = (MyFormBean) form;
>
> fb.setName("dave");
>
> and forward to your form.
>
> dave
>

The struts-example application follows exactly this pattern as well.  It
is quite common.

Craig


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

Reply via email to