How do i pull the last records from different tables all with various amounts of records in them? here is some of my code, but it is returning nothing as my last set of records:
@HandlesEvent("showFirst")
public Resolution showFirst() {
setFirstRecord(1);
setLastRecord(10);
return defaultHandler();
}
private int firstRecord = 1;
public void setFirstRecord(int firstRecord) {
this.firstRecord = firstRecord;
}
public int getFirstRecord() {
return Math.max(1, firstRecord);
}
private int lastRecord = 10;
public void setLastRecord(int lastRecord) {
this.lastRecord = lastRecord;
}
public int getLastRecord() {
int last = Math.max(getFirstRecord(), lastRecord);
AutoFile file = getFile();
if (file != null)
last = Math.min(last, file.getSize());
return last;
}
private int sortBy = -1;
public void setSortBy(int sortBy) {
this.sortBy = sortBy;
}
public int getSortBy() {
return sortBy;
}
@HandlesEvent("showPrevious")
public Resolution showPrevious() {
int numberOfRecords = getLastRecord() - getFirstRecord() + 1;
setFirstRecord(getFirstRecord() - numberOfRecords);
setLastRecord(getFirstRecord() + numberOfRecords - 1);
return defaultHandler();
}
@HandlesEvent("showNext")
public Resolution showNext() {
int numberOfRecords = getLastRecord() - getFirstRecord() + 1;
setLastRecord(getLastRecord() + numberOfRecords);
setFirstRecord(getLastRecord() - numberOfRecords + 1);
return defaultHandler();
}
@HandlesEvent("showLast")
public Resolution showLast() {
AutoFile file = getFile();
if (file != null) {
int lastRecord = file.getSize();
int firstRecord = lastRecord - 9;
setFirstRecord(firstRecord);
setLastRecord(lastRecord);
}
return defaultHandler();
}