Struts, Logic:Iterate & ArrayList of ArrayList of Strings
Hi,
I was wondering if someone could help me with a problem I'm having. Part of my web application requires that I allow the user to choose the columns he wishes to perform an SQL query on.
Because I can't use <bean:write property=".../> tags (what the application shows will change according to the query performed), I chose to create an ArrayList of ArrayLists of Strings where each string should represent one element of one row.
I declare my ArrayList of ArrayList of Strings as follows:
private java.util.ArrayList<java.util.ArrayList<java.lang.String>> employeeList = new java.util.ArrayList<java.util.ArrayList<java.lang.String>>();
Inside of a while loop in the same class, I create new employee records:
while (rs.next())
{
ArrayList<String> employee = new ArrayList<Employee>();
employee.add(rs.getString(1));
...
employee.add(rs.getString(19);
this.employeeList.add(employee);
}
The employeeList is then returned:
return employeeList;
In my action class, I declare an ArrayList:
private ArrayList employeeList = new ArrayList();
And I call on the method above to fill it with the appropriate data:
employeeList = a.doPost(...)
And set it to the session:
session.setAttribute("sqlemployees", employeeList);
On my results page:
<logic:iterate id="employee" name="sqlemployees">
<tr>
<logic:iterate id="element" name="employee" indexId="index">
<td>
<bean:write name="element"/>
</td>
</logic:iterate>
<./tr>
</logic:iterate>
which returns a org.apache.JasperException:
javax.servlet.ServletException: Cannot find bean: "element" in any scope
javax.servlet.jsp.JspException: Cannot find bean: "element" in any scope
If I iterate through the index, 19 values will show with the correct number of records. If I bean:write the employee itself, it will show as [element1,element2...].
I'd really appreciate any help I can get!
Thanks in advance,
Alex