}
public Object invoke(FacesContext facesContext, Object[] aobj)
throws EvaluationException {
if (aobj[0] instanceof PageActionEvent) {
PageActionEvent pageEvent = (PageActionEvent) aobj[0];
UIData sheet = pageEvent.getSheet();
int first = -1;
if (LOG.isDebugEnabled()) {
LOG.debug("action = '" + pageEvent.getAction().name() + "'");
}
int start;
switch (pageEvent.getAction()) {
case FIRST:
first = 0;
break;
case PREV:
start = sheet.getFirst() - sheet.getRows();
first = start < 0 ? 0 : start;
break;
case NEXT:
if (sheet.hasRowCount()) {
start = sheet.getFirst() + sheet.getRows();
first = start > sheet.getRowCount() ? sheet.getLastPageIndex() : start;
} else {
if (sheet.isAtEnd()) {
first = sheet.getFirst();
} else {
first = sheet.getFirst() + sheet.getRows();
}
}
break;
case LAST:
first = sheet.getLastPageIndex();
break;
case TO_ROW:
start = pageEvent.getValue() - 1;
if (start > sheet.getLastPageIndex()) {
start = sheet.getLastPageIndex();
} else if (start < 0) {
start = 0;
}
first = start;
break;
case TO_PAGE:
start = pageEvent.getValue() - 1;
if (LOG.isDebugEnabled()) {
LOG.debug("start = " + start + " sheet.getRows() = "
+ sheet.getRows() + " => start = " + (start * sheet.getRows()));
}
start = start * sheet.getRows();