Forums Register Login

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

+Pie Number of slices to send: Send
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:


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.
snakes are really good at eating slugs. And you wouldn't think it, but so are tiny ads:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 814 times.
Similar Threads
How to sort the result return from a web service.
Sorting ArrayList of MemberBean objects
Sorting the fields of a table
Fetching Rows From ResultSets (JDBC).
paging resultset in servlets
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 29, 2024 06:29:33.