You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Jeff Oberlander <Je...@onename.com> on 2002/02/04 17:11:08 UTC

collecting parameters from a dynamic form

I have a dynamic form that is built from an ArrayList of objects (see below
(b) ).  Building the form works great.  I get multiple rows of widget names
and values.  However, I can't seem to collect the data in my Action.  The
HTML that is rendered just repeats the same named input fields (see below
(b)).  In my action, my widget ArrayList comes in with the right number of
objects, but they are blank (no data has been collected from the form).  A 

request.getParameter("name"));
request.getParameter("value"));

works, but of course only returns one of the sets of data - the first in the
form.  So I can't seem to retrieve the multiple values from in my Action
class in any way.  Am I doing something that can't be done?

(a)
<input type="text" name="name" >
<input type="text" name="value" >
 <input type="text" name="name" >
<input type="text" name="value" >

(b)
<html:form action="/saveWidgets">
<logic:iterate id="element" name="widgetForm" property="widgets">
<table >
  <tr>
    <th >
     Widget Name
    </th>
    <td  >
     <html:text name="element" property="name">
    </td>
  </tr>
  <tr>
    <th >
     Widget Value
   </th>
    <td  >
     <html:text name="element" property="value">
    </td>
  </tr>
</logic:iterate>
</html:form>


Thanks

Jeff




http://www.xns.org/=jeffoberlander 

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: collecting parameters from a dynamic form

Posted by Marcus Brito <pa...@animegaiden.com.br>.
Em Seg, 2002-02-04 às 14:11, Jeff Oberlander escreveu:
> request.getParameter("name"));
> request.getParameter("value"));
> 
> works, but of course only returns one of the sets of data - the first in the
> form.  

Take a look at the HttpServletRequest API. If you need to get multiple
values for a parameter, you need to use the getParameterValues() method.

-- 
Ja ne,
   Pazu
   mailto: pazu@animegaiden.com.br

Anime Gaiden: de fãs para fãs, sempre.