Dear Ravi,

Use indexed properties... 
I am pasting some basic code for you.

Hope it helps,
Ajay

JSP Page
--------

<html:form name="TestForm" type="test.TestForm" action="/test">
<logic:iterate name="TestForm" 
       property="indexedBeans" id="indexedBeans"
    <!-- Please note that id in logic:iterate tag should match
         the name in html:text tag -->
    <html:text name="indexedBeans" property="prop1" indexed="true" />
    <html:text name="indexedBeans" property="prop2" indexed="true" />
</logic:iterate>
</html:form>

Form Class
----------

public ArrayList getIndexedBeans() {
  return this.myBeans;
}

// THIS METHOD IS REQUIRED IF YOUR FORM IS OF REQUEST SCOPE.
public MyBean getIndexedBeans(int index) {

  while (this.myBeans.size() < index) 
    this.myBeans.add(new MyBean());

  return (MyBean) this.myBeans.get(index);
}

Bean Class
----------

public class MyBean {
  private String prop1;
  private String prop2;
  
  public String getProp1() { 
   return prop1; 
  }
  
  public void setProp1(String prop1) {
   this.prop1 = prop1:
  }

  public String getProp1() {
   return this.prop2;
  }

  public void setProp2(String prop2) {
    this.prop2 = prop2;
  }
}




Hi all,
    I am new to struts and what I know is that property name in a JSP 
must be same as that of the variable name in formbean. 
    I have a JSP which has a various fields which are dynamicaly 
generated and the the number of fields is also not same every time. 
      The biggest problem is that there is no upper limit to number of 
these fields. So form bean cannot be be designed as the number of 
fields in the JSP is not fixed. Is there any solution to this problem?

Regards,
Ravi





---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to