You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by David Graham <dg...@hotmail.com> on 2002/07/29 18:24:49 UTC
Prefilling ActionForm Data
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.
Thanks,
Dave
_________________________________________________________________
Chat with friends online, try MSN Messenger: http://messenger.msn.com
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Prefilling ActionForm Data
Posted by "Craig R. McClanahan" <cr...@apache.org>.
On Mon, 29 Jul 2002, Dave Weis wrote:
> Date: Mon, 29 Jul 2002 11:53:40 -0500 (CDT)
> From: Dave Weis <dj...@sjdjweis.com>
> Reply-To: Struts Users Mailing List <st...@jakarta.apache.org>
> To: Struts Users Mailing List <st...@jakarta.apache.org>
> 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: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Prefilling ActionForm Data
Posted by Dave Weis <dj...@sjdjweis.com>.
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
--
Dave Weis "I believe there are more instances of the abridgment
djweis@sjdjweis.com of the freedom of the people by gradual and silent
encroachments of those in power than by violent
and sudden usurpations."- James Madison
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>