Hello,
I am trying to use a nested List<List<MyObject>> with a Struts 2 Action and
a JSP page. I would like to iterate through the JSP page to display the
existing data, allow the user to edit the data, and post the form to a
second Action. However, my second Struts Action always receives back a null
list. I think that my indexing in the JSP page is incorrect. Does anyone
have any suggestion about the correct way to index a nested list on the JSP
page?
This is how I am currently setting my indices:
myList[0][0].property
myList[0][1].property
....
myList[1][0].property
.......
My JSP code looks like:
<s:iterator value="myList" status="outerStat">
<s:iterator value="myList[#outerStat.index]" status="innerStat">
<s:textfield
name="myList[%{#outerStat.index}][%{#innerStat.index}].property"
value="%{property}" />
</s:iterator>
</s:iterator>
Inside my second Struts action, I have the following code (the first action
merely retrieves the list from the database and it works correctly since the
JSP does populate correctly with all of the db records):
private List<List<MyObject>> myList = new ArrayList<List<MyObject>>();
public List<List<MyObject>> getMyList() { return myList; }
public void setMyList(List<List<MyObject>> numbers) { myList = numbers; }
// this execute method is called when posting the form and always returns
null
// when the user is done updating the information
// even though the first action correctly populated the JSP page
public String execute() {
for (List<MyObject> theList : myList) {
if (theList == null) {
System.out.println("received a null list");
}
}
}
Thanks!
--
View this message in context:
http://www.nabble.com/Iterating-over-a-List-of-Lists-tp23824944p23824944.html
Sent from the Struts - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]