Monday, 23 July 2012

Paging Component In LWUIT


Paging Component for J2ME using the LWUIT API


Paging Component:
J2ME phones have very limited memory so its very important for the developers to use that memory efficiently . Paging is one such method which can help us save memory by providing the complete content to the user in an organized manner. If the server side API is designed so as to provide paging the paging component can be used to provide user to switch between pages in a very organized manner.
The paging component accepts a PaginableObject , Total Item count.
Other than this the ItemCount for 1 page and total pages shown at once can be constant as these are not going to change for an application.

Code Snippet:-
public PagingComponent(final Paginable p, int noOfFriends) {
//code to show paging component
}


Paginable Interface

This interface is implemented by all the forms on which we want a PagingComponent to be shown. It has a method onPageChange which accepts the current pageNumber for which the list needs to be updated.

public interface Paginable {
   public void onPageChange(int pageNumber);
}

Use Cases:

The PagingComponent object is created on a form on which we want to implement the Pagination. Generally considering the mobile screen sizes we have shown 10 items in one page and total 5 buttons for changing pages and a left and right button to increase or decrease the page number. We need to have a variable in our form to keep track of current page .

Limit variable or argument at server side will accept the value = no of items that you want to show on single page.

While offset will have the value = currentPage*No of items on one page


For the code please refer the following:


https://docs.google.com/open?id=0B8ZY9NBZj0LPbTBqWEFkRTFIdWs

No comments:

Post a Comment