Pagination in jsf

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);
    //set Rows "0" or "5"
    if(getDisplayResults().size() - (htdbl.getFirst() +5)>5 )
    {
        htdbl.setRows(5);//display 5 rows
    }else if (getDisplayResults().size() - (htdbl.getFirst() +5)<=5) {
        htdbl.setRows(0);//display all rows (which are less than 5)
        setShowNext(false);
    }
    //set First
    htdbl.setFirst(htdbl.getFirst()+5);
    return "success";
}

public String goPrev()
{

    setShowNext(true);
    UIData htdbl = getBrowseResultsHTMLDataTable1();

    //set First
    htdbl.setFirst(htdbl.getFirst()-5);

    if(htdbl.getFirst()==0)
    {
        setShowPrev(false);
    }

    //set Rows - always display 5
    htdbl.setRows(5);//display 5 rows

    return "success";
}
+5
1

, .

, . , , , . : . Tomahawk (, ). JSF2 + Facelets JSF1 + JSP, ui:repeat @ViewScoped t:dataList t:saveState.

+1

All Articles