struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Steve" <>
Subject RE: Iterating over a List of Lists
Date Tue, 02 Jun 2009 11:07:03 GMT
This works for me

<s:iterator value="outerList">

My inner list is a list of Strings.

This code gives me one innerList list per line

Hope this helps,


-----Original Message-----
From: DavidCAIT [] 
Sent: 02 June 2009 02:14
Subject: Iterating over a List of Lists


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

This is how I am currently setting my indices:


My JSP code looks like:

<s:iterator value="myList" status="outerStat">
       <s:iterator value="myList[#outerStat.index]" status="innerStat">
value="%{property}" />

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
// 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");

View this message in context:
Sent from the Struts - User mailing list archive at

To unsubscribe, e-mail:
For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message