This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Struts and the fly likes how to update data via list in Struts2 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "how to update data via list in Struts2" Watch "how to update data via list in Struts2" New topic
Author

how to update data via list in Struts2

namehas beentaken
Greenhorn

Joined: Dec 17, 2011
Posts: 2
Hi, everyone. I am new to Struts2, and I am trying to build a phone bill calcualte page. I use list to contain and successfully display them in the text fileds in jsp page. however, when I modify the data and submit, the action class does not catch anything and the list become null. Can anyone help me through it?
First, I declear a class PhoneMember which has my own attributes. (name, extra minutes cost ...) all of them are String type.
then, In action class I define the list and setter/getter
then I initial 5 elements and add them in the list. I also define a String parameter "total" for total cost.
later in jsp page, I use iterator
the initial value displayed successfully, but when I click the submit button, the phoneList in action class is null. all the data have been lost. But the "total" parameter receives the value;
Can any one helps me to solve this problem? I googled but can't find a solution. I also tried define another list in the action class and use that list name in the iterator. But neither lists get the data. Thanks very much
Nitin Surana
Ranch Hand

Joined: Jan 21, 2011
Posts: 129

This example exactly does what you want.

http://www.onlinexamples.com/showfullexample.action?idexamples=11&title=Iterator%20over%20an%20array/list%20of%20objects/beans

Advanced Example

http://www.onlinexamples.com/showfullexample.action?idexamples=10&title=Nested%20Iterators%20Example
namehas beentaken
Greenhorn

Joined: Dec 17, 2011
Posts: 2
Thanks for the help, Nitin. Finally I find the reason, it is necessary to define an empty constructor in bean file.
 
jQuery in Action, 2nd edition
 
subject: how to update data via list in Struts2
 
Similar Threads
unable to do validation for select in struts2
Passing arraylist as hidden variable in JSP Struts2 framework
How to retain automatically generated fields on pageload in struts2
editing cells in table - not working
Populate list using Struts2