You need to sign in to do that
Don't have an account?
Zabi Mohammed
Pagination in visual force page
Dear All,
I have a test case code coer proble in my controller we are using pagination the record we are having 2000+ for that we used bellow code how to cover that code with test case
public void lastAction() {
bondList = new List<Bond__c>();
offSetNumber = totRecCnt - Math.mod(totRecCnt, defaultPageSize);
/*if((totreccnt - offSetNumber) == 0) {
offSetNumber = totreccnt-defaultPageSize;
} */
system.debug('..........................'+offSetNumber);
if(offSetNumber >2000){
searchString = ' Bond_Status__c !=null and recordtypeId = \''+PrivateBond_Helper.retrieveRecordType(Label.PrivateBondRecType)+'\'';
List<Bond__c> tempBondList = PrivateBond_Helper.RecordsNavigation(searchString);
if(offSetNumber != totRecCnt){
system.debug('.......JA........'+offSetNumber);
for(integer recIndex=offSetNumber; recIndex < totRecCnt; recIndex++){
bondList.add(tempBondList[recIndex]);
}
}else{
offSetNumber = totRecCnt-defaultPageSize;
for(integer recIndex=offSetNumber; recIndex < totRecCnt; recIndex++){
bondList.add(tempBondList[recIndex]);
}
}
}
}
how to cover this in test class i am getting list index out of bound exception
thanks,
zabi
I have a test case code coer proble in my controller we are using pagination the record we are having 2000+ for that we used bellow code how to cover that code with test case
public void lastAction() {
bondList = new List<Bond__c>();
offSetNumber = totRecCnt - Math.mod(totRecCnt, defaultPageSize);
/*if((totreccnt - offSetNumber) == 0) {
offSetNumber = totreccnt-defaultPageSize;
} */
system.debug('..........................'+offSetNumber);
if(offSetNumber >2000){
searchString = ' Bond_Status__c !=null and recordtypeId = \''+PrivateBond_Helper.retrieveRecordType(Label.PrivateBondRecType)+'\'';
List<Bond__c> tempBondList = PrivateBond_Helper.RecordsNavigation(searchString);
if(offSetNumber != totRecCnt){
system.debug('.......JA........'+offSetNumber);
for(integer recIndex=offSetNumber; recIndex < totRecCnt; recIndex++){
bondList.add(tempBondList[recIndex]);
}
}else{
offSetNumber = totRecCnt-defaultPageSize;
for(integer recIndex=offSetNumber; recIndex < totRecCnt; recIndex++){
bondList.add(tempBondList[recIndex]);
}
}
}
}
how to cover this in test class i am getting list index out of bound exception
thanks,
zabi
Please see the link below:
http://blogforce9.blogspot.com.au/2013/11/pageblocktableenhanceradv-yet-another.html
Basically, you can install it into your salesforce org. It will then be a component inside your org, after this it is simply a matter of adding this tag to your page, i guess the best place would be under the apex:page tag:
<c:PageBlockTableEnhancerADV targetPbTableIds="pbtSur" pageSizeOptions="5,10,15" defaultPageSize="5" enableExport="False"/>
where it says targetPbTableIds="pbtSur", just put your pageblocktable id in, exampel:
<apex:pageBlockTable value="{!account.Transactions__r}" var="Tra" cellPadding="4" border="4" id="pbtSur">
The pageblocktable will morph into a new skin and you will be able to use pagination among other things, just remember to isntall the pageblocktable enhancer by following the links on the website.
Best regards
Naga Kiran