wood burning stoves 2.0*
The moose likes Struts and the fly likes Submit form text fields (group) with same name!!! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Submit form text fields (group) with same name!!!" Watch "Submit form text fields (group) with same name!!!" New topic
Author

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

Moniphal Say
Ranch Hand

Joined: Aug 11, 2004
Posts: 48
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Submit form text fields (group) with same name!!!
 
Similar Threads
Submit form text fields (group) with same name
Validation rule for array of objects.
Trouble with indexed properties
Problem with indexed property !
can't get indexed form property to work.