File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes Iterate tag - only the first value of the form variable received when submitted. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Iterate tag - only the first value of the form variable received when submitted." Watch "Iterate tag - only the first value of the form variable received when submitted." New topic
Author

Iterate tag - only the first value of the form variable received when submitted.

Johnny Brown
Greenhorn

Joined: Jul 27, 2009
Posts: 10
I use an ArrayList to iterate and build textboxes inside that. When that form is submitted, only the first value (first textbox) is sent.
If I use String array in getter and setter, I face ClassCast problem when the page gets loaded first time. Following is my code. Can any one help me to figure out where I am doing wrong? Thanks guys.

Data object:


JSP:


This is how I populate data into the ArrayList


Data gets displayed when the page loads first time.
When submitting, only the first value of every month are passed (there can be multiple rows - say multiple January values). Only the first of that gets to Action.
Not sure where I go wrong.
Tim McGuire
Ranch Hand

Joined: Apr 30, 2003
Posts: 820

You have to use a string array in getters and setters. How else can they handle multiple values with the same name?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Iterate tag - only the first value of the form variable received when submitted.
 
Similar Threads
How to Validate this?
Struts Iterator
ArrayList inside an ArrayListVO
Struts: No getter method for property name problem
autoselect the radio button if the list has only 1 item