ArrayList arrayList=(ArrayList)session.getAttribute("FeeTypeCodeValues");
String nfp=request.getParameter("option");
int arrayListSize = arrayList.size();
int NFRecords=0;
log.info("the nfp value="+nfp+"the Nfrecords="+NFRecords);
if(nfp==null)
NFRecords=5;
else
NFRecords=Integer.parseInt(nfp);
log.info("From select box the no of records=========***********"+NFRecords);
log.info("The arralist==="+arrayList);
int NoOfColums=5;
log.info("The Arraylist size=========="+arrayListSize+"========(arrayListSize%5)/5=="+(arrayListSize/NoOfColums)%NFRecords);
int NoOfPages=0;
if((arrayListSize/NoOfColums)%NFRecords==0)
NoOfPages=((arrayListSize/NoOfColums)/NFRecords);//First 5 is for NoOfColumns and Second 5 is for NoOfRecords per page
else
NoOfPages=((arrayListSize/NoOfColums)/NFRecords)+1;
int count=1;
log.info("NoOfPages================="+NoOfPages+"======count=="+count);
// Number of Records that need to displayed per page
int increment = NoOfColums*NFRecords;//Number of Records perpage including colums count(NumberOfColumsperOneRecord*NumberRecords)
int fromIndex = 0;
int toIndex = increment;
boolean check = true;
String uri = request.getRequestURI();
String previous="";
String next ="";
List displayList = null;
if( null != request.getParameter("next"))
{
fromIndex = Integer.parseInt(request.getParameter("next"));
toIndex = increment + fromIndex;
count=Integer.parseInt(request.getParameter("count"));
count++;
if( toIndex+1 > arrayListSize)
{
toIndex = arrayListSize;
check = false;
}
if( fromIndex > arrayListSize)
fromIndex = 0;
}
if( null != request.getParameter("prev"))
{
toIndex = Integer.parseInt(request.getParameter("prev"));
fromIndex = toIndex - increment;
count=Integer.parseInt(request.getParameter("count"));
count--;
}
if(arrayListSize > 0)
{
if(increment > arrayListSize){
toIndex = arrayListSize;
displayList = arrayList.subList(fromIndex, toIndex);
toIndex = 0;
}else{
displayList = arrayList.subList(fromIndex, toIndex);
}
}
if(fromIndex != 0 )
previous = " Previous ";
if(toIndex != 0 && check)
next = " Next ";
Thanks&Regards
Sreenivas Reddy.T
No comments:
Post a Comment