Grouping Data with JSP or JSTL
Hi All,
I would like to ask a question about how I can group data in JSP. Essentially, I have a DataBean (extends ArrayList) that is being returned to my JSP. The ArrayList contains HashTables. Please note that the JSP assumes the data is returned in sorted order. This JSP is not responsible for sorting the data itself.
[UPDATED EXAMPLE]
For example, here is what the data might look like:
Column A Column B Column C
12 3
11520
45 6
49966
78 9
101112
Here is how I would use my DataBean:
String column1Name =bundle.getString(揷olumnA.title?;
String column2Name =bundle.getString("columnB.title");
String column3Name =bundle.getString("columnC.title");
/* Loop through the bean. */
for (int i=1;i<myDataBean.size();i++){
Hashtable reportRow=myDataBean.get(i);
String column1Value=reportRow.get(Constants.COLUMNA);
String column2Value=reportRow.get(Constants.COLUMNB);
String column3Value=reportRow.get(Constants.COLUMNC);
}
Question
If I want to change my layout/display to group by a particular column. How would I do that without changing the data structure that is running my current DataBean? Below is an example of grouping by the values in ColumnA.
ColumnA: 1
ColumnB ColumnC
2 3
1520
ColumnA: 4
ColumnB ColumnC
5 6
9966
ColumnA: 7
ColumnB ColumnC
8 9
ColumnA: 10
ColumnB ColumnC
1112
Your help is very much appreciated.
Thanks!>

