Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Submit form text fields (group) with same name!!!

 
Moniphal Say
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
I am new to Structs,I've just use it last 2 weeks, now i found some problem which is simarly to Girish Varde posted last month(july 09, 2004 5:49 AM). My question is :
I want to display identical text fields in a form which should be as many as required, decided dynamically.
I use logic:iterate to iterate over my list of informations and I have put some input:text for each iterate.
How can I take a group of value of text fields with same name?

I've saw the reply of Marc Peabody and Srikanth Shenoy to Girish Varde, and I've try with that code but it still doesn't work.

Here is my code in the JSP page :

<table>
<% int counter=0; %>
<logic:iterate id="indexInfo" name="indexInfoList">
<tr>
<td>.......</td>
</tr>
<td>
<c:choose>
<c:when test="${indexInfo.dataType !='2'}">
Enter the string please :
<html:text indexed="true" property='<%= "indexValue[" + counter++ + "]" %>'/>
</c:when>
<c therwise>
Enter the number please :
<html:text indexed="true" property='<%= "indexValue[" + counter++ + "]" %>'/>
</c therwise>
</c:choose>

</td>
</tr>
</logic:iterate>
</table>

And this is my action Form:

private String[] indexValue = new String[0];

public String[] getIndexValue() {
return indexValue;
}

public void setIndexValue(String[] strings) {
indexValue = strings;
}

But it is doesnt work since my JSP page.


The error message is :

java.lang.ArrayIndexOutOfBoundsException
java.lang.reflect.Array.get(Native Method)
org.apache.commons.beanutils.PropertyUtils.getIndexedProperty(PropertyUtils.java:525)
org.apache.commons.beanutils.PropertyUtils.getIndexedProperty(PropertyUtils.java:428)
org.apache.commons.beanutils.PropertyUtils.getNestedProperty(PropertyUtils.java:770)
org.apache.commons.beanutils.PropertyUtils.getProperty(PropertyUtils.java:801)
org.apache.struts.util.RequestUtils.lookup(RequestUtils.java:952)
org.apache.struts.taglib.html.BaseFieldTag.doStartTag(BaseFieldTag.java:176)
org.apache.jsp.verticalForm_jsp._jspService(verticalForm_jsp.java:282)
..................................


So please help me to solve this problem !!!

Thanks.
Regards,
moniphal
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic