aspose file tools
The moose likes Struts and the fly likes how to update data via list in Struts2 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 "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.
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: how to update data via list in Struts2
 
Similar Threads
How to retain automatically generated fields on pageload in struts2
editing cells in table - not working
unable to do validation for select in struts2
Populate list using Struts2
Passing arraylist as hidden variable in JSP Struts2 framework