Welcome to Dream.In.Code
Become a Java Expert!

Join 149,516 Java Programmers for FREE! Get instant access to thousands of Java experts, tutorials, code snippets, and more! There are 1,367 people online right now. Registration is fast and FREE... Join Now!




How to keep track of how many records to display in a page.

 
Reply to this topicStart new topic

How to keep track of how many records to display in a page., How to keep track of how many records to display in a page.

jadeite100
28 Jun, 2007 - 05:59 AM
Post #1

New D.I.C Head
*

Joined: 12 Jun, 2007
Posts: 4


My Contributions
Hi All:

I am using Weblogic 9.2, Web Services Client, and Struts.
I have a java client in struts that calls a web services.
The "ID" field contains a Java integer.
The "First_Name" is a Java String.
The "Effective_Date" field is a Java date field.
The web service returns an arrayList of a class called Result.

Code for Result.java:
QUOTE

public class Result
{
int id;
String first_Name;
Date effective_Date;

public int getId
{
return id;
}

public void setId(int id)
{
this.id=id;
}

public String getFirst_Name()
{
return first_Name;
}

public void setFirst_Name(String first_Name)
{
this.first_Name = first_Name;
}

public Date getEffective_Date()
{
return effective_Date;
}

public void setEffective_Date(Date effective_Date)
{
this.effective_Date=effective_Date;
}

}



From the arrayList, I displayed the result as the following:

ID FIRST_NAME EFFECTIVE_DATE
-- --------- -------------
3 John 9/10/2007
2 Andrew 1/11/2006
5 Peter 3/4/2006

The "ID" header is a link.
The "First Name" header is a link.
The "EFFECTIVE_Date" is a link.

If I clicked on the link "ID", the first time, it will sort the rows in ascending
order like the following:

ID FIRST_NAME EFFECTIVE_DATE
-- --------- -------------
2 Andrew 1/11/2006
3 John 9/10/2007
5 Peter 3/4/2006

If I clicked on the link "ID", the second time, it will sort the rows in descending
order like the following:
ID FIRST_NAME EFFECTIVE_DATE
-- --------- -------------
5 Peter 3/4/2006
3 John 9/10/2007
2 Andrew 1/11/2006

If I clicked on the "First_Name" field the first time, it will sort the rows in
desceding order.
If I clicked on the "First_Name" field the second time, it will sort the rows in
ascending order.

This applies the same for the "EFFECTIVE_DATE".

If the arrayList returns 80 records of class Results.java.
I needed to displayed only the first 50 records for the first page and 30 records for the second page.
How do I keep track of that so that when I am in the second page, I know to display only record 51 to 80?

If I have a arrayList that returns 120 records of class Results.java.
In the first page, it displayed only 50 records.
In the second page, it displayed only 50 records.
In the third page, it displayed only 20 records.

Assuming I am able to sort the rows by ID, FirstName and Effective_Date by using Results.java implementing the
Java Comparator class. Is it still possible to keep track of how many records displayed in the first page and how many records should
be dispalyed in the second page?



Any hint would be greatly appreciate.

Yours,

Frustrated.

User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/7/09 08:09PM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live Java Help!

Java Tutorials

Reference Sheets

Java Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month