DUE TO SPAM, SIGN-UP IS DISABLED. Goto Selfserve wiki signup and request an account.
How to make NavigationToolbar hide paging components at limits
First create a MyDefaultDataTable by copying org.apache.wicket.extensions.markup.html.repeater.data.table.DefaultDataTable.
This allows for us to pass our own MyNavigationToolbar. If there is a better way please let me know.
MyDefaultDataTable
public class MyDefaultDataTable extends DataTable {
public MyDefaultDataTable(String id, final List columns,
ISortableDataProvider dataProvider, int rowsPerPage) {
this(id, (IColumn[]) columns.toArray(new IColumn[columns.size()]),
dataProvider, rowsPerPage);
}
public MyDefaultDataTable(String id, final IColumn[] columns,
ISortableDataProvider dataProvider, int rowsPerPage) {
super(id, columns, dataProvider, rowsPerPage);
addTopToolbar(new MyNavigationToolbar(this));
addTopToolbar(new HeadersToolbar(this, dataProvider));
addBottomToolbar(new NoRecordsToolbar(this));
}
protected Item newRowItem(String id, int index, IModel model) {
return new OddEvenItem(id, index, model);
}
}
Next create MyNavigationToolbar and override the paging component creation methods.
MyNavigationToolbar
public class MyNavigationToolbar extends NavigationToolbar {
public MyNavigationToolbar(DataTable table) {
super(table);
}
@Override
protected PagingNavigator newPagingNavigator(String navigatorId, DataTable table) {
return new PagingNavigator(navigatorId, table) {
@Override
protected Link newPagingNavigationIncrementLink(String id, IPageable pageable, int increment) {
return new PagingNavigationIncrementLink(id, pageable, increment) {
@Override
public boolean isVisible() {
return !linksTo(getPage());
}
};
}
@Override
protected Link newPagingNavigationLink(String id, IPageable pageable, int pageNumber) {
return new PagingNavigationLink(id, pageable, pageNumber) {
@Override
public boolean isVisible() {
return !linksTo(getPage());
}
};
};
};
}
}