Hello, I am trying to pick up the changes made to a collection on a submitted form. The collection created looks like the following:
<logic:iterate id="secGrp" name="selRptSpec" property="rptSpecAsgn" indexId="keyValue" >
<tr>
<td><html:checkbox indexed="true" name="secGrp" property="checked" />
</td>
<td>
<bean:write name="secGrp" property="displayVal" />
</td>
<td><html:text indexed="true" name="secGrp" property="description" size="55" maxlength="100" />
</td>
<td><html:text indexed="true" name="secGrp" property="appValue" size="3" maxlength="3" />
</td>
</tr>
</logic:iterate>
"rptSpecAsgn" is an ArrayList of assignment objects. The assignment class has getters and setters for each of the member variables. In my action form I have code for reseting the collection as well as the getter and setter methods.
All standalone fields on the form are submitted and mapped to thier corresponding variables in the actionForm class with the exception of the rptSpecAsgn collection. I can set the values for each item in the collection and they are displayed correctly in the JSP, but when I submit the form the collection returns empty.
I am not sure what I am doing wrong here, but I have aged 10 fold getting this to work. Any assistance would be greatly appreciated.
Thanks,
Shawn
Discussions
Web tier: servlets, JSP, Web frameworks: Submitting changes made to Collection/ArrayList
-
Submitting changes made to Collection/ArrayList (8 messages)
- Posted by: Shawn Martin
- Posted on: February 01 2005 11:34 EST
Threaded Messages (8)
- reset by Ash H on February 01 2005 11:45 EST
- reset by Shawn Martin on February 01 2005 11:57 EST
- Same problem by sudhindra shetty on April 27 2005 23:50 EDT
- Indexed properties by jayaprakash tr on April 28 2005 07:27 EDT
- j2sdk1.4 doesnt handle ArrayList by sam segal on April 29 2005 10:24 EDT
-
reset[ Go to top ]
- Posted by: Ash H
- Posted on: February 01 2005 11:45 EST
- in response to Shawn Martin
I guess if you are reseting collectionin the reset method then it is being called after the form submit...This will happen if you are trying to call soem other method in the same action on submit.
I had similar problem to overcoem this I had to create my own reset method which i call from action only when needed.
Hope this helps
Ash -
reset[ Go to top ]
- Posted by: Shawn Martin
- Posted on: February 01 2005 11:57 EST
- in response to Ash H
Thanks for the quick response. I removed any code associated with the collection from the reset method and still no luck. ??? -
hidden[ Go to top ]
- Posted by: Ash H
- Posted on: February 01 2005 12:02 EST
- in response to Shawn Martin
Try to create a hidden property for this collectionin the form and see if it submits.
Ash -
hidden[ Go to top ]
- Posted by: Shawn Martin
- Posted on: February 01 2005 12:12 EST
- in response to Ash H
I am not sure what you mean. I tried to create
<html:hidden property="rptSpecAsgn" />
and when I accessed the page I recieved the following exception:
javax.servlet.ServletException: BeanUtils.populate
at org.apache.struts.util.RequestUtils.populate(RequestUtils.java:1254)
...
...
java.lang.IllegalArgumentException: argument type mismatch
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
??? -
form[ Go to top ]
- Posted by: Ash H
- Posted on: February 02 2005 12:14 EST
- in response to Shawn Martin
Hi,
Not sue why you have that exception.It should have worked if you have commented reset method lines and have html:form tag properly embedding your required feilds within it on the jsp...If you won't mind you post your jsp here. -
Same problem[ Go to top ]
- Posted by: sudhindra shetty
- Posted on: April 27 2005 23:50 EDT
- in response to Shawn Martin
I am facing the same problem. Did you find any solution for this???? -
Indexed properties[ Go to top ]
- Posted by: jayaprakash tr
- Posted on: April 28 2005 07:27 EDT
- in response to Shawn Martin
Solution for this problem is clearly defined at
http://www.developer.com/java/ejb/article.php/2233591
go and check it. May contact me at jpe123in at yahoo dot com for clarifications.
Regards.
jp -
j2sdk1.4 doesnt handle ArrayList[ Go to top ]
- Posted by: sam segal
- Posted on: April 29 2005 10:24 EDT
- in response to Shawn Martin
Not sure what the difference is yet but i ran into this problem today when upgrading to j2sdk1.4 from 1.3. After reading another forum somebody suggested that a difference in reflection API between 1.3 and 1.4 is causing this. changing the ArrayList in the form to be an Object[] fixed the issue.