"Andy Engle" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > [EMAIL PROTECTED] wrote: > > > Richard, > > Its not necessary to use ActionForm, but it is always better to use > > one(its my philosophy). But yes it will work the way you are doing > > it. But i rather prefer a ActionForm which can also help in future > > for any validation or in future if decided to add more attributes to > > the form.. > > With this discussion in mind, I am wondering if there is any way I can > use an ActionForm in the following scenario: I would like to have a > list of fields, dynamically created, with names that have been > dynamically created along with those fields. So, for example, I would > have a series of input fields like this: > > <input type="text" name="field_1"> > <input type="text" name="field_2"> > <input type="text" name="field_3"> > > The "field_" part of the name value will stay, but the number will > change. With these field name values being so dynamic, is there any > trick I can use to feed all this into an ActionForm? I don't think > there is, unless I am missing something...
I don't believe it can be done with the fields named like that, but there is a trick you might be able to use. ;-) 1) In the <input> elements, use names of the form "dynaFields.field_1", etc. The name isn't important, but the dot is. 2) Create a corresponding Map property in your form bean (i.e. a property named "dynaFields" in this example). When your action form is populated, you will end up with the "dynaFields" map containing key/value pairs corresponding to the name/value pairs from your <input> elements. -- Martin Cooper > > > Thanks, > Andy --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]