• Post Reply Bookmark Topic Watch Topic
  • New Topic

how to add row in display table using display tag?  RSS feed

 
Happy S Singh
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
how to add row in display table using display tag based on the calculation of previous row?
 
Winston Gutkowski
Bartender
Posts: 10575
66
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Happy S Singh wrote:how to add row in display table using display tag based on the calculation of previous row?

1. Get the previous row.
2. Do the calculation.
3. Add a new row with the result.

But I suspect that's not what you wanted to know. Please TellTheDetails (←click).

Winston
 
Happy S Singh
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am setting the values from resultset to formbean which is in turn used to display table on jsp

while(iResultSet1.next())
{
afWIPZonalRpt Objafwipzonalrpt = new afWIPZonalRpt();
Integer i=0;

Objafwipzonalrpt.setMis(iResultSet1.getString(++i));
Objafwipzonalrpt.setCentral(iResultSet1.getString(++i));
Objafwipzonalrpt.setEast(iResultSet1.getString(++i));
Objafwipzonalrpt.setFrontier(iResultSet1.getString(++i));
Objafwipzonalrpt.setNorth(iResultSet1.getString(++i));
Objafwipzonalrpt.setSouth(iResultSet1.getString(++i));
Objafwipzonalrpt.setSvv(iResultSet1.getString(++i));
Objafwipzonalrpt.setWest(iResultSet1.getString(++i));
Objafwipzonalrpt.setGrandTotal(iResultSet1.getString(++i));

expRptCol.add(Objafwipzonalrpt);
}

My question is how to get last two rows from the resultset, do the summation and add one more row at the bottom?
 
fred rosenberger
lowercase baba
Bartender
Posts: 12565
49
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1) Get the 2nd to last row
2) Get the last row
3) Do the summation
4) add one more row.

Now, I'm going to go out on a limb, and guess that your question is REALLY: How do I know when I get to the last two rows?

you either need to query the result set to see how many rows there are ahead of time (I'm not sure if this is possible), or you need to save each row as it comes in. Then, when you get the next row, move the previous one up, and save this one...in other words, you have:

lastRowData;
secondLastRowData;

each time you read a row, you move what's in lastRowData to secondLastRow, and then store the current in lastRow.

you then have to account for the possibility that you have zero or one row, but that shouldn't be too hard.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!