aspose file tools
The moose likes Struts and the fly likes Struts2 Populate ArrayList from JSP Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Frameworks » Struts
Reply Bookmark "Struts2 Populate ArrayList from JSP" Watch "Struts2 Populate ArrayList from JSP" New topic
Author

Struts2 Populate ArrayList from JSP

Tom Rispoli
Ranch Hand

Joined: Aug 29, 2008
Posts: 349
Hi Everyone, I'm new to struts2 and I'm having trouble getting data entered into an html form to populate an ArrayList the way I want it to when I delete a row from an html table that holds input fields that are populated from the ArrayList. Instead of populating every element in the ArrayList it leaves a null Element in the ArrayList where the row was deleted. I'm converting my application from a struts 1.2.7 application and the behavior in 1.2.7 was to fill in all the elements in the ArrayList and not leave nulls where the row was removed. I don't want to have to change my application to deal with these null rows or write code to remove them if there is a way to get struts2 to behave the way struts 1 did.

Maybe this example will make what I'm saying more clear:

JSP


And the row is being deleted on the screen by javascript that looks like this:


If the iterator loops 5 times and puts 5 hidden fields on the screen and the javascript is called to delete the third one then when the form is submitted the ArrayList will have elements in its first two and list two positions, but the third position will be null.

Please let me know if there is a way around this. Also, if someone could point me to a description of how struts2 process when it moves data from an html form to java fild that would be helpful as well.

Thanks
Tom
Tom Rispoli
Ranch Hand

Joined: Aug 29, 2008
Posts: 349
Found my problem, I'm new to java 6 (and 5 for that matter) I wasn't using the generics notation consistently.
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Struts2 Populate ArrayList from JSP
 
Similar Threads
Page navigation using struts2
struts2:Displaying dtatbase values in jsp
How to retain automatically generated fields on pageload in struts2
iterate problem in struts2
struts2 iterator tag