Digg-Style Pagination in Java
The following is something like a translation of Digg-Style Pagination into java.
public ArrayList getPagingLinks(){
ArrayList pages = new ArrayList();
if (pageCount < (7 + (adjacents * 2))){
for(int i=1; i<=pageCount; i++){
pages.add(i);
}
} else if(currentPage < ((adjacents * 3) + 1)){
for(int i=1; i<=(4 + (adjacents * 2)); i++){
pages.add(i);
}
pages.add("e");
pages.add(pageCount);
} else if(((pageCount - (adjacents * 2)) > currentPage) && (currentPage > (adjacents * 2))){
pages.add(1);
pages.add("e");
for(int i=currentPage -adjacents; i<=currentPage +adjacents; i++){
pages.add(i);
}
pages.add("e");
pages.add(pageCount);
} else{
pages.add(1);
pages.add("e");
for(int i=pageCount - (adjacents *3); i<=pageCount; i++){
pages.add(i);
}
}
return pages;
}
Basically, it creates a list of links to pages determined by the displayCount. If the page number equals the current page or the page number is greater than the page count, then no link will be added, only the page number.
Multiline Comments with Ruby
I didn’t know that ruby
has multiline comments.
- =begin
Name:
Last Updated:
Location:
...
=endWell, at least I wasn’t the only one.

