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.

Page 1 of 1

0 Replies - 1046 Views - Last Post: 28 June 2007 - 06:59 AM Rate Topic: -----

#1 jadeite100  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 12-June 07

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

Posted 28 June 2007 - 06:59 AM

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.

Is This A Good Question/Topic? 0
  • +

Page 1 of 1