|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
|
|
#1
|
|||
|
|||
|
display data in certain number of rows
after i retrieve the data from the database, there is a very long list of data. is there a way to display them in rows of ten or twenty?
What i have now is: <% while (rs.next()) { <% out.println(rs.getString(1)); %> <%} rs.close(); statement.close(); %> Pls help.... |
|
#2
|
|||
|
|||
|
Do you mean display the first 10, or display 10 per page with multiple pages?
|
|
#3
|
|||
|
|||
|
display 10 per page with multiple pages
|
|
#4
|
|||
|
|||
|
There are taglibs that will let you do what you want, or you can write your own classes that let you do what you want.
I did the latter. A summary: A DataGrid class holds the data. Keeping a ResultSet object open ties up db resources, so the data is transferred to a List of Lists inside the DataGrid object. DataGrid has a constructor that takes a ResultSet as an argument. A PaginatedReport object displays the data. It has a DataGrid as a field as well as pageSize and currentPage ints. It has previous(), next() setPage() methods that navigate thru pages, and a toHTMLTable method that spits out the data in a single String in HTML format. So the steps are: 1. get the ResultSet from your db. 2. create a DataGrid from the ResultSet 3. create a PaginatedReport from the DataGrid 4.put the PaginatedReport in the session 5. call toHTMLTable on the PaginatedReport object. 6. put "next" and "previous" links on your page, and add logic to the jsp to call the next() or previous() methods of the PaginatedReport. |
|
#5
|
|||
|
|||
|
wat are the taglibs???
i dunno how to write the class.. |
|
#6
|
|||
|
|||
|
This help? http://www.jguru.com/faq/view.jsp?EID=60818
|
|
#7
|
|||
|
|||
|
i don't understand what the storing of data in a java bean mean...
is it possible to show me the codes??? currently, i have: <% while(rs.next()){ String srno = rs.getString(1); %> <tr> <td width="10%"><font size=2> <a href="checkboxselect.jsp?srno=<%= srno%>"> <%= srno%> <!-- <% out.println(rs.getString(1));%> --> </a> </font></td> <td width="11%"><font size=2> <% out.println(rs.getString(2));%> </font></td> <td width="11%"><font size=2> <% out.println(rs.getString(3));%> |
|
#8
|
|||
|
|||
|
Here's a link off that page. A taglib to do it all for you
Read the docs. http://jsptags.com/tags/navigation/pager/ |
|
#9
|
|||
|
|||
|
after i download the executable jar, what do i do???
|
|
#10
|
|||
|
|||
|
Read the documentation under "installation".
|
|
#11
|
|||
|
|||
|
my tomcat server is an integrated version therefore it does not have the folder that it mention.
is there another way like using short jsp codes instead??? |
|
#12
|
|||
|
|||
|
Well, the source for the taglib is included in a jar file in the download, so you could reimplement the classes that do the work and use them stand-alone.
However, I'm willing to bet your IDE comes with documentation on how to enable a custom taglib. Check it's help page. |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Java Help > display data in certain number of rows |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|