Apologies for following up a user-type question with another one, but in the interests of (brain) bandwith I don't read the user list. Please forgive me, I won't do it again :-)
If this approach is used, populating the form bean before the form is displayed, then it means that hitting a "Reset" button will, rather than clearing the form, clear out any user modifications and re-fill the form with the values that the bean was populated with in the previous step. Now, I know that this is the expected, or even required behaviour from the point of view of HTML. However, when I had one site going through testing, the tester complained that a particular form was broken because the reset button kept on filling in the values instead of clearing them. In this particular case, it was clear that what was required was not a "reset" button, but a "clear all the fields" button. So, getting to the point (eventually), I know that it's possible to do this server-side, by having a button which will just cause the form bean to have all its properties set to null and redirect back to the input page. However, is there a way to do this client-side? Regards Colin M Sharples I/T Architect IBM Global Services New Zealand email: [EMAIL PROTECTED] phone: 64-4-5769853 mobile: 64-21-402085 fax: 64-4-5765616 "Craig R. McClanahan" To: Struts Developers List <[EMAIL PROTECTED]> <craigmcc@apac cc: he.org> Subject: Re: form initialization Sent by: [EMAIL PROTECTED] m.com 13/12/2001 19:30 Please respond to "Struts Developers List" On Wed, 12 Dec 2001, Jon Burford wrote: > Date: Wed, 12 Dec 2001 20:40:34 -0800 > From: Jon Burford <[EMAIL PROTECTED]> > Reply-To: Struts Developers List <[EMAIL PROTECTED]> > To: [EMAIL PROTECTED] > Subject: form initialization > > Greetings! > > I have a dynamic form which needs to be initialized from the database. > If I put code to initialize the attributes in the default constructor > of the form bean, all this happens with no problems - the form is > displayed with the proper values. My problem is that the form bean > needs some of the request parameters from the calling jsp page in > order to properly initialize its fields. What is the preferred way of > form bean initialization and how can it access request parameters at > initialization time? I used a couple hidden form fields which the jsp > page initialized to the corresponding request parameters, but this > does not take effect until AFTER the constructor is called. Any help > would be much appreciated. > This type of question is really more suited for the STRUTS-USER list. The design pattern I prefer is exemplified in the Struts Example application -- use an Action to set up the form bean *before* the form is displayed. In the example app, note how an "Edit Subscription" transaction is handled: * The "/editSubscription" action is called to pre-fill the SubscriptionForm bean and place it in request scope. If you need values from the request that triggered this, they are accessible to the Action and it can call setters as needed. * This action forwards to "subscription.jsp" which shows the pre-filled-out form. * The submit goes to the "/saveSubscription" action which updates the database (assuming successful validation). > TIA! > Jon > > Craig McClanahan -- 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]>