Hi,
I am writing some code which is going to display data from DB using Hibernate pagination concept. Here , i am facing the issue with bg color for table rows. i want to put different colors (first row should be light blue and second row should be light gray color. Here is my code.
-----------------
Session ses=factory.openSession();
Criteria crit1=ses.createCriteria(registergoods.class);
crit1.setProjection(Projections.rowCount());
List l1=crit1.list();
Iterator it1=l1.iterator();
if(it1.hasNext())
{
Object o=it1.next();
totNumberOfRecords=Integer.parseInt(o.toString());
}
Criteria crit2=ses.createCriteria(registergoods.class);
crit2.addOrder(Order.desc("purchasedon"));
crit2.setFirstResult((pageIndex*numberOfRecordsPerPage)-numberOfRecordsPerPage);
crit2.setMaxResults(numberOfRecordsPerPage);
List l2=crit2.list();
Iterator it2=l2.iterator();
Criteria crit3=ses.createCriteria(registergoods.class);
crit3.setProjection(Projections.sum("amount"));
List l3=crit3.list();
Iterator it3=l3.iterator();
while(it3.hasNext())
{
am=(Integer)it3.next();
Amount=Double.parseDouble(Integer.toString(am));
System.out.println("am is ::"+Amount);
}
Double bal=26870.00-Amount;
System.out.println("Balance is :: "+bal);
pw.println("<table width=100% border=0 bgcolor=#0299FF><tr><td width=20%>");
pw.println("<font color=Green size=4 valign=right> Balance: ");
pw.println("</td></font><td width=35%>"+bal);
pw.println("</td>");
pw.println("<td width=35%><font color=Red size=4 valign=right> Purchased Amount as on Date is");
pw.println("</td></font><td width=10%>"+Amount);
pw.println("</td></tr></table><br>");
pw.println("<center><table border=0 width=80%>");
pw.println("<tr bgcolor=brown><td><b>ID</b></td> <td><b>PRODUCT</b></td> <td> <b>QUANTITY</b></td> <td><b>AMOUNT</b></td> <td><b>PURPOSE</b></td> <td><b>PURCHASEDON</b></td> </tr>");
while(it2.hasNext())
{
registergoods rg=(registergoods)it2.next();
pw.println("<tr>");
pw.println("<td><input type=checkbox name=check value="+rg.getId()+"></td>");
//pw.println("<td>"+rg.getId()+"</td>");
pw.println("<td>"+rg.getProduct()+"</td>");
pw.println("<td>"+rg.getQuantity()+"</td>");
pw.println("<td>"+rg.getAmount()+"</td>");
pw.println("<td>"+rg.getPurpose()+"</td>");
pw.println("<td>"+rg.getPurchasedon()+"</td>");
pw.println("</tr>");
}
pw.println("</table>");
pw.println("<input type=submit value=Delete>");
int noOfPages=totNumberOfRecords/numberOfRecordsPerPage;
if(totNumberOfRecords>(noOfPages*numberOfRecordsPerPage))
{
noOfPages=noOfPages+1;
}
pw.println("<br>");
for(int i=1;i<=noOfPages;i++)
{
String url="srv2?pageindex="+i;
pw.println("<b><a href="+url+">"+ " |"+i+"|</a></b>");
}
pw.println("</center>");
ses.close();
pw.close();
-------------------
The bold one should fetch the data from DB using resultset, I want to use a color for the first iteration and other color for second iteration like that i want to use total 2 colors..
so please help me in this
Thanks in advance.
Shiva javascript:emoticon('
');