RE: how to initialize an edit page?
I'm using struts 1.2.9 but your case seems pretty standard. 1. yes, you should include the form name in your mapping 2. if necessary, in your action access the "id" from either the request or the form 3. get your data and populate the form 4. do not create form beans yourself If you still have problem please post your mapping and action code From: Rick Schumeyer [mailto:[EMAIL PROTECTED] Sent: Tue 12/12/2006 8:55 AM To: Struts Users Mailing List Subject: how to initialize an edit page? this is a struts 1.3.5 question. I am looking for an example of an edit cycle. Let's say I have a list of employee names; If I click on one I want to have a page to edit the employee values. The initial click would call an action that queries the database, gets the employee data, and stores it...where exactly? The initial click did not come from a form, and so does not have an associated ActionForm (or should it?) The edit page will have an associated ActionForm, but we are not there yet. I could just "pass" an ActionForm bean to the edit page via request.setAttribute()? As you can see, I'm a bit confused on this point. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] ** This message is intended for the addressee named and may contain privileged information or confidential information or both. If you are not the intended recipient please delete it and notify the sender. ** - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: how to initialize an edit page?
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Rick, Rick Schumeyer wrote: > I am looking for an example of an edit cycle. Let's say I have a list > of employee names; If I click on one I want to have a page to edit the > employee values. > > The initial click would call an action that queries the database, gets > the employee data, and stores it...where exactly? > > The initial click did not come from a form, and so does not have an > associated ActionForm (or should it?) Your spidey-sense is tingling correctly, Rick. The way that Struts is intended to be used is that you associate a form bean with your "edit" action, but set it to validate="false". Then, in your action, grab the (empty) form bean and fill it with information from your database (or wherever). Then, forward (not redirect) to your display page (JSP, velocity, whatever). In your view page, use the data in the form bean as the values for all of your form fields. When you save, and validation fails, the form bean will contain non-validated data. I assume that you have set your edit forward and your save action's "input" to the same thing: this makes it easy to use the same page to display fresh-from-the-database data as well as re-displaying invalid submission data for correction. > The edit page will have an associated ActionForm, but we are not there yet. You can have your element contain a "name" (form bean) as well as a "forward" (shortcut to your page... i.e. no custom action) and it will work properly (your form bean will be empty). - -chris -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.6 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFFffZr9CaO5/Lv0PARAswJAJwNxaBt4zmfirX6L7psBFrY30JWYgCgjOnT y+uxpIqj2OGTSmCuyVxBH0s= =2egv -END PGP SIGNATURE- - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
how to initialize an edit page?
this is a struts 1.3.5 question. I am looking for an example of an edit cycle. Let's say I have a list of employee names; If I click on one I want to have a page to edit the employee values. The initial click would call an action that queries the database, gets the employee data, and stores it...where exactly? The initial click did not come from a form, and so does not have an associated ActionForm (or should it?) The edit page will have an associated ActionForm, but we are not there yet. I could just "pass" an ActionForm bean to the edit page via request.setAttribute()? As you can see, I'm a bit confused on this point. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]