You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Richard Yumul <rm...@polexis.com> on 2001/03/15 22:25:48 UTC

populating a Form from a DB?

What's the process to dynamically populate a form?  For example, say I click
on a link w/ a URL something like:

user.jsp?userid=34

How would I code the user.jsp (and/or the accompanying classes) to fill in
the form in user.jsp with user# 34's data in a struts-centric way?

(If there's documentation somewhere on how to do this, please let me know,
thanks)

Thanks,
Rich

Richard M. Yumul
Polexis, Inc.
Direct: 619-542-7209
Fax: 619-542-8675
http://www.polexis.com
transforming data into knowledge


Re: populating a Form from a DB?

Posted by "Craig R. McClanahan" <cr...@apache.org>.

On Thu, 15 Mar 2001, Richard Yumul wrote:

> What's the process to dynamically populate a form?  For example, say I click
> on a link w/ a URL something like:
> 
> user.jsp?userid=34
> 
> How would I code the user.jsp (and/or the accompanying classes) to fill in
> the form in user.jsp with user# 34's data in a struts-centric way?
> 
> (If there's documentation somewhere on how to do this, please let me know,
> thanks)
> 

The Struts example application does exactly this sort of trick.

On the registration.jsp page, do a View Source and look at the links in
the table of subscriptions down at the bottom -- specifically the edit
links.  You will see that they link back to an action
(/editSubscription.do) rather than directly to a page.  Which subscription
is being referenced is passed as query parameters.

The /editSubscription action looks up the existing subscription,
prepopulates the ActionForm bean, and forwards to the subscription.jsp
page for display.  When you submit the updated subscription, it goes to a
different action (/saveSubscription) to be stored in the database.

> Thanks,
> Rich
> 

Craig McClanahan


Re: populating a Form from a DB?

Posted by David Winterfeldt <dw...@yahoo.com>.
I normally do something like:
  user.do?action=getInfo&userid=34

Then based on the action, you can populate the bean
with the info you want and forward it the jsp page.

David

--- Richard Yumul <rm...@polexis.com> wrote:
> What's the process to dynamically populate a form? 
> For example, say I click
> on a link w/ a URL something like:
> 
> user.jsp?userid=34
> 
> How would I code the user.jsp (and/or the
> accompanying classes) to fill in
> the form in user.jsp with user# 34's data in a
> struts-centric way?
> 
> (If there's documentation somewhere on how to do
> this, please let me know,
> thanks)
> 
> Thanks,
> Rich
> 
> Richard M. Yumul
> Polexis, Inc.
> Direct: 619-542-7209
> Fax: 619-542-8675
> http://www.polexis.com
> transforming data into knowledge
> 


__________________________________________________
Do You Yahoo!?
Get email at your own domain with Yahoo! Mail. 
http://personal.mail.yahoo.com/