java - Displaying retrieved data from GAE datastore in two different html tables -
here code fetches data datastore , displays them in single html table. now, want classify data based on statusdate variable, , display them in 2 different html tables.
<h2 align="center">the list of companies details given below:</h2> <table> <tr> <td>company name</td> <td>ctc</td> <td>10th %</td> <td>puc/diploma</td> <td>engg</td> <td> history bclog</td> <td>current bclog</td> <td>year gap</td> <td>visiting date</td> <td>status</td> </tr> <% simpledateformat formatter = new simpledateformat("dd/mm/yyyy"); date date=new date(); datastoreservice datastore = datastoreservicefactory.getdatastoreservice(); query q=new query("placementdb"); preparedquery pq= datastore.prepare(q); for(entity p1:pq.asiterable()){ string company_name=p1.getproperty("companyname").tostring(); string hist_bclog=p1.getproperty("historybacklogs").tostring(); string current_bclog=p1.getproperty("currentbacklogs").tostring(); string year_gap=p1.getproperty("yeargap").tostring(); string ctc=p1.getproperty("ctcoffered").tostring(); double tenth=double.parsedouble(p1.getproperty("10th%").tostring()); double twelth=double.parsedouble(p1.getproperty("12th%").tostring()); double cgpa1=double.parsedouble(p1.getproperty("cgpa").tostring()); string dateofvisit =p1.getproperty("dateofvisit").tostring(); date dateofvisit1 =formatter.parse(p1.getproperty("dateofvisit").tostring()); string eligible_branch=p1.getproperty("eligiblebranches").tostring(); int comp_h; int comp_c; int comp_y; string statusdate; if(dateofvisit1.after(date)){ statusdate="upcoming"; // display in table 1 } else{ statusdate="past"; // display in table 2 } if(hist_bclog.equals("yes")){ comp_h=1; } else{ comp_h=0; } if(current_bclog.equals("yes")){ comp_c=1; } else{ comp_c=0; } if(year_gap.equals("yes")){ comp_y=1; } else{ comp_y=0; } if(eligible_branch.contains(branch)){ if(ten>=tenth && twelve>=twelth && cgpa >=cgpa1){ if(comp_h==1 && comp_c==1 && comp_y==1){ eligibility_flag="eligible"; } else if((history_bl <= comp_h) && (current_bl <=comp_c) && (yeargap <= comp_y)){ eligibility_flag="eligible"; } else{ eligibility_flag="not eligible"; } } else{ eligibility_flag="not eligible"; } %> <tr> <td><%=company_name%></td> <td><%=ctc%></td> <td><%=tenth%></td> <td><%=twelth%></td> <td><%=cgpa1%></td> <td><%=hist_bclog%></td> <td><%=current_bclog%></td> <td><%=year_gap%></td> <td><%=dateofvisit %></td> <td><%=eligibility_flag %></td> <td><%=status_date %></td> </tr> <% } } } %> </table> </body> </html>
you can placing each entity 1 of 2 lists.
linkedlist<entity> upcomingstatusentities = new linkedlist<entity>(); linkedlist<entity> paststatusentities = new linkedlist<entity>(); for(entity p1:pq.asiterable()){ date dateofvisit1 =formatter.parse(p1.getproperty("dateofvisit").tostring()); if (dateofvisit1.after(date)){ upcomingstatusentities.add(p1); } else{ paststatusentities.add(p1); } }
now can iterate on each of these lists create each table. copy table displaying code this, should make function displaying kind of table , call twice, once each list. this article explains how place java functions in jsp file.
Comments
Post a Comment