function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
reem sharawyreem sharawy 

related opportunities with pagination

hi
I am trying to create a vf page to fetch related opportunities for specific account and to add pagination.
Whenever I try to save my code I get the below error:
Error: Compile Error: Method does not exist or incorrect signature: [ListPaginationBase].initializePagination(List<NewStockTransferExtension.materialWrapperList>, Integer) 
 
public class NewStockTransferExtension{

    public ListPaginationBase ConstructionOpportunityList {get; set;}
    
    public list<materialWrapperList> materialWrapperList{get;set;}
  
    public Account currentAccount {get; set;}

    public NewStockTransferExtension(ApexPages.StandardController controller) {
        ConstructionOpportunityList = new ListPaginationBase();
        currentAccount = (Account) controller.getRecord();

       
        ConstructionOpportunityList.initializePagination(materialWrapperList, 20);
       
    }
        public class materialWrapperList
        {
            public  boolean checked{get;set;}
            Public Opportunity ConstructionOpportunityList {get;set;}
            public materialWrapperList(Opportunity ConstructionOpportunityList ){
            this.ConstructionOpportunityList = ConstructionOpportunityList ;
            }
         }



}

 
Best Answer chosen by reem sharawy
karthikeyan perumalkarthikeyan perumal
Hello, 

Use below updated Test class.  you forget to call the standard controller constructor. 
 
@isTest 
                   
Private class TestCESExtension {
        static testmethod void CESExtension_Test (){
        
            Test.startTest(); 
            
            Account a2 = new Account(Name ='icrm testing acc');
            insert a2;
            
            opportunity opp = new opportunity(Name='testing DIE 4/6/2015' ,  AccountId= a2.Id,StageName = 'Prospecting', 
                                   type= 'parts', Description= 'describe',   CloseDate = System.today().addDays(30));
            insert opp;
            
            
            CES__c CES = new CES__c (
                Estimated_Order_Date__c = System.today().addDays(30),
                Opportunity_Name__c = opp.id
                );
           insert CES;
		   
            ApexPages.StandardController sc = new ApexPages.StandardController(CES);
            CESExtension   obj = new CESExtension (sc);

           Test.stopTest();

        }
            
        static testmethod void updateCES(){
        
            Account a2 = new Account(Name ='icrm testing acc');
            insert a2;

            opportunity opp = new opportunity(Name='testing DIE 4/6/2015' ,  AccountId= a2.Id,StageName = 'Prospecting', 
                                   type= 'parts', CloseDate = System.today().addDays(30));
            insert opp;
            
            
            CES__c CES = new CES__c(
                
                id = 'a158E000000mEyO',
                CurrencyIsoCode = 'USD',
                Delivery_status__c = 'Delivered',
                Estimated_Order_Date__c = System.today().addDays(30),
                Reseller_site_address__c = 'address'
                
                );

           ApexPages.StandardController sc = new ApexPages.StandardController(CES);
           CESExtension   obj = new CESExtension (sc);

           update CES;

        }

}

Hope this will help you, 

Thanks
karthik
 

All Answers

karthikeyan perumalkarthikeyan perumal
Hello, 

Use Below code, if its not work try to post  "ListPaginationBase"  code for checking. 
 
public class NewStockTransferExtension{

    public ListPaginationBase ConstructionOpportunityList {get; set;}
    
    public list<materialWrapperList> lstmaterialWrapperList {get;set;}
  
    public Account currentAccount {get; set;}

    public NewStockTransferExtension(ApexPages.StandardController controller) {
        ConstructionOpportunityList = new ListPaginationBase();
        currentAccount = (Account) controller.getRecord();

       
        ConstructionOpportunityList.initializePagination(lstmaterialWrapperList, 20);
       
    }
        public class materialWrapperList
        {
            public  boolean checked{get;set;}
            Public Opportunity ConstructionOpportunityList {get;set;}
            public materialWrapperList(Opportunity ConstructionOpportunityList ){
            this.ConstructionOpportunityList = ConstructionOpportunityList ;
            }
         }



}

Hope this will help you. 

mark it solved if its work for you. 

Thanks
karthik

 
reem sharawyreem sharawy
Thanks a lot Karthik , it's working now 
karthikeyan perumalkarthikeyan perumal
Mark it best ANSWER if its work for you.. 

Thanks
karthik
 
reem sharawyreem sharawy
Hello

I worte the below helper class and it is working perfetly, but I have an issue with the deployment because of the test class
 
public class CESExtension {

  public CES__c CES;
  public opportunity Opp;
  public CES_Line_Item__c lineitem;
  
  
  public CESExtension (ApexPages.StandardController stdController) {
    
    CES__c CES = (CES__c )stdController.getRecord();
    List<opportunity> opp = [SELECT Id, type
                              FROM opportunity
                              WHERE Id = :CES.Opportunity_Name__c];
        if(opp.size() > 0){
            CES.Opportunity_Name__r= opp[0];
        }
    
    }    
 
}

test class
@isTest 
                   
Private class TestCESExtension {
        static testmethod void CESExtension (){
        
            Test.startTest(); 
            
            Account a2 = new Account(Name ='icrm testing acc');
            insert a2;
            
            opportunity opp = new opportunity(Name='testing DIE 4/6/2015' ,  AccountId= a2.Id,StageName = 'Prospecting', 
                                   type= 'parts', Description= 'describe',   CloseDate = System.today().addDays(30));
            insert opp;
            
            
            CES__c CES = new CES__c (
                Estimated_Order_Date__c = System.today().addDays(30),
                Opportunity_Name__c = opp.id
                );
           insert CES;
           
           Test.stopTest();

        }
            
        static testmethod void updateCES(){
        
            Account a2 = new Account(Name ='icrm testing acc');
            insert a2;

            opportunity opp = new opportunity(Name='testing DIE 4/6/2015' ,  AccountId= a2.Id,StageName = 'Prospecting', 
                                   type= 'parts', CloseDate = System.today().addDays(30));
            insert opp;
            
            
            CES__c CES = new CES__c(
                
                id = 'a158E000000mEyO',
                CurrencyIsoCode = 'USD',
                Delivery_status__c = 'Delivered',
                Estimated_Order_Date__c = System.today().addDays(30),
                Reseller_site_address__c = 'address'
                
                );
           
           update CES;

        }

}

please help
reem sharawyreem sharawy
I don't get an error , but the code coverage is zero 
karthikeyan perumalkarthikeyan perumal
Hello, 

Use below updated Test class.  you forget to call the standard controller constructor. 
 
@isTest 
                   
Private class TestCESExtension {
        static testmethod void CESExtension_Test (){
        
            Test.startTest(); 
            
            Account a2 = new Account(Name ='icrm testing acc');
            insert a2;
            
            opportunity opp = new opportunity(Name='testing DIE 4/6/2015' ,  AccountId= a2.Id,StageName = 'Prospecting', 
                                   type= 'parts', Description= 'describe',   CloseDate = System.today().addDays(30));
            insert opp;
            
            
            CES__c CES = new CES__c (
                Estimated_Order_Date__c = System.today().addDays(30),
                Opportunity_Name__c = opp.id
                );
           insert CES;
		   
            ApexPages.StandardController sc = new ApexPages.StandardController(CES);
            CESExtension   obj = new CESExtension (sc);

           Test.stopTest();

        }
            
        static testmethod void updateCES(){
        
            Account a2 = new Account(Name ='icrm testing acc');
            insert a2;

            opportunity opp = new opportunity(Name='testing DIE 4/6/2015' ,  AccountId= a2.Id,StageName = 'Prospecting', 
                                   type= 'parts', CloseDate = System.today().addDays(30));
            insert opp;
            
            
            CES__c CES = new CES__c(
                
                id = 'a158E000000mEyO',
                CurrencyIsoCode = 'USD',
                Delivery_status__c = 'Delivered',
                Estimated_Order_Date__c = System.today().addDays(30),
                Reseller_site_address__c = 'address'
                
                );

           ApexPages.StandardController sc = new ApexPages.StandardController(CES);
           CESExtension   obj = new CESExtension (sc);

           update CES;

        }

}

Hope this will help you, 

Thanks
karthik
 
This was selected as the best answer
reem sharawyreem sharawy
thanks a lot karthik, it is working now