SunQuest
           Java Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesJava Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
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  
Old August 15th, 2002, 07:35 PM
peter83 peter83 is offline
Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2002
Posts: 19 peter83 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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....

Reply With Quote
  #2  
Old August 15th, 2002, 11:01 PM
bricker42 bricker42 is offline
Moderator =(8^(|)
Dev Shed Intermediate (1500 - 1999 posts)
 
Join Date: Feb 2002
Location: Sacramento, CA
Posts: 1,710 bricker42 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 20 m 38 sec
Reputation Power: 8
Send a message via AIM to bricker42
Do you mean display the first 10, or display 10 per page with multiple pages?

Reply With Quote
  #3  
Old August 15th, 2002, 11:13 PM
peter83 peter83 is offline
Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2002
Posts: 19 peter83 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
display 10 per page with multiple pages

Reply With Quote
  #4  
Old August 16th, 2002, 12:38 AM
preaney preaney is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2001
Posts: 16 preaney User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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.

Reply With Quote
  #5  
Old August 16th, 2002, 12:47 AM
peter83 peter83 is offline
Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2002
Posts: 19 peter83 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
wat are the taglibs???

i dunno how to write the class..

Reply With Quote
  #6  
Old August 16th, 2002, 12:51 AM
bricker42 bricker42 is offline
Moderator =(8^(|)
Dev Shed Intermediate (1500 - 1999 posts)
 
Join Date: Feb 2002
Location: Sacramento, CA
Posts: 1,710 bricker42 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 20 m 38 sec
Reputation Power: 8
Send a message via AIM to bricker42

Reply With Quote
  #7  
Old August 16th, 2002, 01:52 AM
peter83 peter83 is offline
Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2002
Posts: 19 peter83 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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));%>

Reply With Quote
  #8  
Old August 16th, 2002, 02:17 AM
bricker42 bricker42 is offline
Moderator =(8^(|)
Dev Shed Intermediate (1500 - 1999 posts)
 
Join Date: Feb 2002
Location: Sacramento, CA
Posts: 1,710 bricker42 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 20 m 38 sec
Reputation Power: 8
Send a message via AIM to bricker42
Here's a link off that page. A taglib to do it all for you Read the docs. http://jsptags.com/tags/navigation/pager/

Reply With Quote
  #9  
Old August 16th, 2002, 02:34 AM
peter83 peter83 is offline
Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2002
Posts: 19 peter83 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
after i download the executable jar, what do i do???

Reply With Quote
  #10  
Old August 16th, 2002, 02:41 AM
bricker42 bricker42 is offline
Moderator =(8^(|)
Dev Shed Intermediate (1500 - 1999 posts)
 
Join Date: Feb 2002
Location: Sacramento, CA
Posts: 1,710 bricker42 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 20 m 38 sec
Reputation Power: 8
Send a message via AIM to bricker42
Read the documentation under "installation".

Reply With Quote
  #11  
Old August 16th, 2002, 02:52 AM
peter83 peter83 is offline
Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2002
Posts: 19 peter83 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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???

Reply With Quote
  #12  
Old August 16th, 2002, 03:10 AM
bricker42 bricker42 is offline
Moderator =(8^(|)
Dev Shed Intermediate (1500 - 1999 posts)
 
Join Date: Feb 2002
Location: Sacramento, CA
Posts: 1,710 bricker42 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 20 m 38 sec
Reputation Power: 8
Send a message via AIM to bricker42
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.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesJava Help > display data in certain number of rows


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway