Depends on how hard you're going to flame me =) Actually yes, but I'm guessing from your tone that I'm being a bad boy.
--- - Nayan Hajratwala - Chikli Consulting LLC - http://www.chikli.com -----Original Message----- From: Iain Sanderson [mailto:[EMAIL PROTECTED]] Sent: Thursday, January 23, 2003 3:59 PM To: Struts Users Mailing List Subject: RE: HOWTO pre-populate forms with data, then update ? Nayan, Are you accessing the business logic ( or database) in the reset method to determine the initial values? Iain Please respond to "Struts Users Mailing List" <[EMAIL PROTECTED]> To: "'Struts Users Mailing List'" <[EMAIL PROTECTED]> cc: Subject: RE: HOWTO pre-populate forms with data, then update ? I have done this by setting up the initial values in the "reset()" method. Is that not the correct way to do it? If not, how do you switch between "prepare actions" and "process actions"? --- - Nayan Hajratwala - Chikli Consulting LLC - http://www.chikli.com -----Original Message----- From: Karr, David [mailto:[EMAIL PROTECTED]] Sent: Thursday, January 23, 2003 3:48 PM To: Struts Users Mailing List Subject: RE: HOWTO pre-populate forms with data, then update ? In general, Struts applications will use "prepare actions" to prepare the data for a form, and "process actions" to process the submitted data for a form. In your "prepare action" code, you'll interface with your business logic to obtain the required data, then populate fields of a bean, probably in request scope, not session scope, then you'll forward to your page view, which will use the request scope bean to populate the form. Your "process action" will then take the fields from the form (populated from the HTML fields) and send the changed values to your business logic. Usually, you can avoid putting most of this bean data into the session scope. -----Original Message----- From: Iain Sanderson [mailto:[EMAIL PROTECTED]] Sent: Thursday, January 23, 2003 12:21 PM To: [EMAIL PROTECTED] Subject: HOWTO pre-populate forms with data, then update ? 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 -- 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]> -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>