• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

how to add row in display table using display tag?

 
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
how to add row in display table using display tag based on the calculation of previous row?
 
Bartender
Posts: 10780
71
Hibernate Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
lowercase baba
Posts: 13089
67
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
When it is used for evil, then watch out! When it is used for good, then things are much nicer. Like this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic