struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Iain Sanderson" <sande...@mc.duke.edu>
Subject HOWTO pre-populate forms with data, then update ?
Date Thu, 23 Jan 2003 20:20:40 GMT
Newbie question:

I've managed to use Struts forms as a means of  initial data entry ( 
registration forms etc) but have got  stuck on how to use a form to update 
data that already exists in a database. For example, a form where a user 
can update their user details (address, email etc) and then submit the 
updates. How is this best done in struts ?

I'm sure there's a good way of doing this, but my Kludge so far has been 
to  create a bean in the session scope containing the data I want to 
populate the form with ( eg a user's current address), and then use struts 
 html:text  tags to view  the bean data using their "name" and "property" 
attributes.   Once the user has submitted their updates, the ActionForm 
accesses the form bean to obtain the updates, and applies the updates to 
the database.   I then of course have to update the  original bean's data 
with the new values ( eg their amended address) and send it back into the 
session scope.  It's a bit of a mess, but it works. 

I know there's a better way. Please help. Thanks.

Iain Sanderson
 
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message