hasan's blog (বল্গ)

work for fun!!!

Archive for October 25th, 2006

iBatis PaginatedList and pagination

with 3 comments

iBatis has very good pagination support. every query can be limited by max number of rows and scrollable.
for example i have executed “queryForPaginatedList( “queryName”, domainObject, MAX_ROWS ) “;
iBatis PaginatedList class is extension of “java.util.List” class. so you can generally use it as collection object.
following methods are added to PaginatedList class:

    int getPageSize();

page size is current size of list (list.size() == MAX_ROWS)

    boolean isFirstPage();

if page offset is 0 no “nextPage” is invoked (default state)

    boolean isMiddlePage();

if between last and first offset (though did not use it, just assumption)

   boolean isLastPage();

if page offset == total available page

boolean isNextPageAvailable();

if current offset is not the last offset

    boolean isPreviousPageAvailable();

if current offset is not set to ’0′ i mean already (nextPage(…)) invoked.

    boolean nextPage();

hit database(or cache) to load next MAX_ROWS number of items

    boolean previousPage();

hit database(or cache) to load rows from certain range from current state to one step backward.

    void gotoPage(int i);

move forcefully to certain page by specified offset

int getPageIndex();

return current page index(offset) number

How to paginate through your records?:

1. let’s think some one accessed your controller, you performed some retrieval task, and stored this “PaginatedList” object into session context.
2. when user request for  “next” page. you just load your object from session and invoke “pgList.nextPage()”
3. when user request for “back/previous” page you just load your object from session and invoke “pgList.previousPage()”
4. and set again in session context.
5. access from view .. and render your desire UI…
regards and Eid Mubarak!!!

Written by nhm tanveer hossain khan

October 25, 2006 at 7:26 pm

Posted in Java, iBatis, java ee

A request !!

with one comment

please stop piracy, stop piracy your favorite music album. stop sharing your favorite album with your the best friend.
rather gift her/him a new favorite album. encourage our talents our artists.
an album does not cost much… but it worth much for an artist… please encourage them…
let them produce more creative artistic album. prove your true love for your loving artist…

my simple request to all folks … STOP PIRACY STOP MUSIC PIRACY FIRST … LET INSPIRE …

Written by nhm tanveer hossain khan

October 25, 2006 at 2:20 pm

Posted in Introduction, request