aspose file tools*
The moose likes Java in General and the fly likes pagination Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "pagination" Watch "pagination" New topic
Author

pagination

veda vyas
Greenhorn

Joined: Apr 11, 2011
Posts: 3
i want to pass pagesize value dynamically from jsp how can i do this ,below i am putting my java class


public IExtendedPaginatedList getPaginatedListFromRequest(HttpServletRequest request){

IExtendedPaginatedList paginatedList = new PaginatedListImpl();
String sortCriterion = request.getParameter(IExtendedPaginatedList.IRequestParameters.SORT);
paginatedList.setSortDirection(IExtendedPaginatedList.IRequestParameters.DESC.equals(request.getParameter(IExtendedPaginatedList.IRequestParameters.DIRECTION))? SortOrderEnum.DESCENDING : SortOrderEnum.ASCENDING);
paginatedList.setSortCriterion(sortCriterion);
int pageSize = 25; // Rows per page
paginatedList.setPageSize(pageSize);
String thePage = request.getParameter(IExtendedPaginatedList.IRequestParameters.PAGE);
if(thePage != null){
int index = paginatedList == null? 0 : Integer.parseInt(thePage) - 1;
paginatedList.setIndex(index);
}else{
paginatedList.setIndex(0);
}

return paginatedList;
}

please help me
Mohamed Sanaulla
Saloon Keeper

Joined: Sep 08, 2007
Posts: 3054
    
  33

Please UseCodeTags and also TellTheDetails - we need to know what is the problem with the code you have provided or what are the exceptions being thrown. You could have a look at PaginationOrPaging which explains some approaches for Pagination.


Mohamed Sanaulla | My Blog
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18126
    
    8

Two things:

(1) Remove the line which hard-codes the number of lines per page.

(2) Pass the number of lines per page as a parameter of the method.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: pagination
 
Similar Threads
Enumeration or a better way
[ Servlet ] Error when I added the init() method to a servlet
help required with pagination
String Problem
Array index out of bound exception