Showing posts from February, 2013

Custom PagingNavigator for SEO friendly URL

Apache Wickets biggest strength is its focus on components - Among a very large set of components is PagingNavigator component. It is a Wicket Panel component to draw and maintain a complete page navigation. I found this component very useful but the only problem that compelled me to write my own CustomPagingNavigator is the wicket URLs that are being created by clicking the page links. 

The Java Part...
public class CustomPaginationLinksPanel<T> extends Panel{
private static final long serialVersionUID = 10002L;
/**Pageable List View to be displayed */
private PageableListView<T> mainView;
/** Max count of links  default  value = 5 */
private intlinksPerPage = 5;
/** Page Number currently visible */
private int currPgNum;
    /** first page number */
private intfirstNum;
/** last page number */
private intlastNum;
//Calculated on the basic of List size
private intmaxPages;
//Parameter name that will be displayed as a part of URL
private String PAGINATOR_PARAM_NAME = "pg";


sorting a List containing Object[] elements

Problem Statement: How can we  sort a List containing Object[] elements?
The Solution: Ever wondered how to sort a list full of Object[]? The answer is to use a Comparator I have used an anonymous class which implements compare method to sort the List of Object[]
package example.collections;
import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; import java.util.List;
publicclass Sorting {
publicstaticvoid main(String[] args) {               List<Object[]> list = new ArrayList<Object[]>();               list.add(new Object[]{123, "abc", 212});               list.add(new Object[]{423, "qwert", 2131});               list.add(new Object[]{656, "asda", 45});               list.add(