struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jason Lea <>
Subject Re: Handling of n number of text boxes at runtime
Date Tue, 16 Sep 2003 05:47:56 GMT
Madala, Srinivasa wrote:

> Hi folks,
>          I am having trouble with my JSP page.The jsp is designed in such a
> way that it can generate n number of text boxes at runtime.So I can't have
> either ActionForm or DynaActionForm which are predefined based on a list of
> properties enumerated in either the Form bean or the Struts configuration
> file and they utilize the properties at the initialization time.I got to
> collect input values from all these n text boxes when I submit the page.Does
> anyone have a clue how to handle this in Struts?Can anyone help me??
> Thanks in advance,
> Srinivas

You can use a map-backed ActionForm eg

public class MyForm extends ActionForm {
   protected Map map=new HashMap();

   public Object getValue(String key) {
     return map.get(key);

   public void setValue(String key, Object value) {
     map.put(key, value);

As for the JSP page you need to specify the property values like so:

<html:text property="value(key)" />

So if you wanted 3 fields called name, description and quantity you 
would use

<html:text property="value(name)" />
<html:text property="value(description)" />
<html:text property="value(quantity)" />

or create some fields in a loop using JSTL and Struts-EL tags

<c:forEach var=”i” begin=”100” end=”110”>
   <html:text property="value(${i})" />

Jason Lea

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message