I would like to receive your comments and suggestions on this subject. I am doing pagination for a page in jsf. The corresponding datatable is bound to the Backing Bean property through the binding attribute. I have 2 boolean variables to determine if the "Prev" and "Next" buttons should be displayed, which is displayed under this datatable. When the "Prev" or "Next" button is clicked, in the Bean database I get the associated dataTable property and through which I get the "first" and "rows" attribute for the datatable and change accordingly. I am showing 5 lines per page. Please comment and suggest if there are any better ways. By the way, I'm not interested in any JSF components, but stick only to the basic set of html rendering.
public String goNext()
{
UIData htdbl = getBrowseResultsHTMLDataTable1();
setShowPrev(true);
if(getDisplayResults().size() - (htdbl.getFirst() +5)>5 )
{
htdbl.setRows(5);
}else if (getDisplayResults().size() - (htdbl.getFirst() +5)<=5) {
htdbl.setRows(0);
setShowNext(false);
}
htdbl.setFirst(htdbl.getFirst()+5);
return "success";
}
public String goPrev()
{
setShowNext(true);
UIData htdbl = getBrowseResultsHTMLDataTable1();
htdbl.setFirst(htdbl.getFirst()-5);
if(htdbl.getFirst()==0)
{
setShowPrev(false);
}
htdbl.setRows(5);
return "success";
}