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
Sasidhar Reddy BSasidhar Reddy B 

Date filters Implement in Controller using wrapper class

Hi Guys,

I'm facing issue is dynamic soql query values wrote from one method. this concept implement everything in controller that controller using wrapper class. 

my scenario is Datefilters concept ,if user gives from date and/or  todate values in page.based on date the table of information is filterd.

Now i'm getting null point argument in displaydetails method. please guide me if you have any idea about wrapper class in SFDC
Before filter Displaying Table :

User-added image

after filter displaying Table::

User-added image
Preya VaishnaviPreya Vaishnavi
Please post your code 
Sasidhar Reddy BSasidhar Reddy B

Date filters Implement in Controller using wrapper class

Controller : 

 public ApexPages.StandardSetController con {
        get {
            if(con == null) {
                
                Id recTypeDealId = LeadRecordTypeInfoByName.get('Deal Registration').getRecordTypeId();
                System.debug('Deal Record Type Id='+recTypeDealId);
                
                String conId = [Select ContactId from User where Id =: UserInfo.getUserId()].ContactId;

                queryString = 'Select Id, Name, company, Partner_Account_Name__c, CreatedBy.Name,Status,Target_End_User__c,Panasonic_Comments__c , testDate__c, State  FROM Lead';  
                
              // sets the number of records in each page 
                      System.debug('queryString>>>>::' );
                        Con = new ApexPages.StandardSetController(Database.getQueryLocator(queryString ));
                        con.setPageSize(20);
                  }
                    return con;
                }
                set;
    }
     public void displaydetails()
    {
        System.debug('## From date: '+fromDate);  
        System.debug('## end date: '+toDate);
        String filter = queryString ;
        String fromDate_d,toDate_d;
        if( fromDate!= null ){
            fromDate_d = fromDate.year() +'-';
            if(fromDate.month() < 10) fromDate_d += '0'+fromDate.month()+'-';
            else fromDate_d += fromDate.month()+'-';

            if(fromDate.day()< 10) fromDate_d += '0'+fromDate.day();
            else fromDate_d += fromDate.day();
        }
        if(toDate != null){
            toDate_d = toDate.year() +'-';
            if(toDate.month() < 10) toDate_d += '0'+toDate.month()+'-';
            else toDate_d += toDate.month()+'-';

            if(toDate.day()< 10) toDate_d += '0'+toDate.day();
            else toDate_d += toDate.day();
        }
        if( fromDate != null && toDate!= null )
            filter=filter+' '+'WHERE testDate__c>='+fromDate_d+'  AND testDate__c <='+toDate_d;
        
        else if(fromDate == null && toDate != null)
            filter=filter+' '+'WHERE  testDate__c<='+toDate_d;
        
        else if(fromDate != null && toDate == null)
            filter=filter+' '+'WHERE testDate__c>='+fromDate_d;
           /////////////////////////////////// 
         con=new ApexPages.StandardSetController(Database.getQueryLocator(filter));
       system.debug('con::'+StandardSetController);
     getting issue 
   
   /////////////////////////////////////////////////////////////
        
        // con.setPageSize(10);
    }
   
    
    
    // returns a list of wrapper objects for the sObjects in the current page set
    public List<LeadWrapper> getLeads() {       
        leadWrapperList = new List<LeadWrapper>();
     
        if(con != null){
          
      
        
            for (Lead oLead : (List<Lead>)con.getRecords()){
                leadWrapperList.add(new LeadWrapper(oLead));
            }
            
        }
        return leadWrapperList;
    }
   
.......................................
VF PAGE:

<apex:pageBlock title="Approved Deals Submitted" >
       <!-- Added by partha -->
        <apex:pageBlockSection id="datefilters" showHeader="true">
              <apex:outputLabel value="From"/>
               <apex:input id="cdfrom" value="{!fromDate}" type="date"/>
               <apex:outputLabel value="To"/>
               <apex:input id="cdto" value="{!toDate}" type="date"/>
            </apex:pageBlockSection>
            
            <apex:pageBlockButtons location="bottom">
            <apex:commandButton action="{!displaydetails}" value="Generate details" ID="ENTER_BUTTON"/>
            </apex:pageBlockButtons> 
       <!-- Added by partha  -->
    <apex:pageBlockButtons location="top">
      </apex:pageBlockButtons>
      <apex:pageMessages />
      
        <apex:pageBlockSection columns="1">
            <apex:pageBlockTable value="{!leads}" var="awrapper" rendered="{!(leads.size != 0)}">
                <apex:column headerValue="Integrator">
                <apex:outputLink onclick="{redirect('{!awrapper.oLead.Id}');}" >{!awrapper.oLead.Partner_Account_Name__c}</apex:outputLink>
                </apex:column>
                <apex:column headerValue="Integrator Contact">
                <apex:outputText value="{!awrapper.oLead.CreatedBy.Name}"/>
                </apex:column>
                <apex:column headerValue="Company">
                <apex:outputText value="{!awrapper.oLead.Company}"/>
                </apex:column>
                <apex:column headerValue="State">
                <apex:outputText value="{!awrapper.oLead.State}"/>
                </apex:column>
                <apex:column headerValue="Submission Date">
                <apex:outputText value="{0, date, dd'/'MM'/'yyyy}" style="align:right;">
                    <apex:param value="{!awrapper.oLead.testDate__c}"/>
                </apex:outputText>
                </apex:column>  
                <apex:column headerValue="Status">
                <apex:outputText value="{!awrapper.oLead.Status}"/>
                </apex:column>                  
            </apex:pageBlockTable>
        </apex:pageBlockSection>