PDA

View Full Version : Help with Grouping in JSP/JSTL


jbassil
06-29-2007, 09:10 PM
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 HashMaps.

For example, here is what the data might look like:

Column A Column B Column C
1 2 3
4 5 6

Here is how I would use my DataBean:

String column1Name =reportsBundle.getString(“columnA.title”);
String column2Name =reportsBundle.getString("columnB.title");
String column3Name =reportsBundle.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

ColumnA: 2
ColumnB ColumnC
4 5

Your help is very much appreciated.
Thanks!