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
Frank CarterFrank Carter 

visualforce page reRender PageReference

Hello,
I need HELP, I have a vf search with wrapper class.
There are two buttons, a search button and another to process the selected records.
The problem is when I click the second button the page block is not rerender,but If I click the Search the records are processed.
This second button called, Moves to Next Month, it changes the date with the current month. This method is PageReference.
I tried to apply the reRender on vf page but searching on the forum I read that reRender doesn't works with PageReference method.
How to reRender only results records and not the entire page?
I need to reRender only resuts because I have to date fields to do the research and I don't want to lose the date set.

vf:
<apex:page controller="SearchWithWrapperC" docType="html-5.0" id="pg">
        <script type="text/javascript">
        function selectAllCheckboxes(obj,receivedInputID){
            var inputCheckBox = document.getElementsByTagName("input");                  
            for(var i=0; i<inputCheckBox.length; i++){          
                if(inputCheckBox[i].id.indexOf(receivedInputID)!=-1){                                     
                    inputCheckBox[i].checked = obj.checked;
                }
            }
        }
    </script>
    <apex:form >
        <apex:pageBlock title="Billing Details Search Page"  >
            <br/>
            <br/>
            <apex:actionRegion >
                <center>
                    <apex:outputLabel value="Start Date"/>
                    <apex:input value="{!StartDate}" type="date" /><br/>
                    <apex:outputLabel value="End Date "/>
                    <apex:input value="{!EndDate}" type="date" /> 
                </center>
            </apex:actionRegion>  
            <br/>
            
            <div align="center" draggable="false" >            
                <apex:commandButton value="Search" action="{!loadData}"  style="text-align:left;" />               
                <apex:commandButton value="Moves to next month"  style="text-align:left;" onclick="if(!confirm('If you click ok all the selected billing details will be paid for the current month. Are you sure? ')) return false;" action="{!processSelected}" reRender="pagination" />  
            </div>        
        </apex:pageBlock>
        
        <apex:pageBlock id="pagination">
            <apex:variable var="listnotnull" value="{!listBD != null}" />
            
            <apex:pageBlockTable value="{!listBD}" var="b" >
                <apex:column >
                    <apex:facet name="header">
                        <apex:inputCheckbox onclick="selectAllCheckboxes(this,'inputId')" rendered="{! listnotnull }"/>
                    </apex:facet>
                    <apex:inputCheckbox value="{!b.check_box}" id="inputId" />
                </apex:column>
                
                <apex:column value="{!b.cs.Name}"/>
                <apex:column value="{!b.cs.SF_Opportunity_Id__c}"/>
                <apex:column style="width:110px" value="{!b.cs.Account_Name__c}"/>
                <apex:column style="width:130px" value="{!b.cs.Billing_Detail__c}"/>
                <apex:column value="{!b.cs.Billing_Type__c}"/>
                <apex:column value="{!b.cs.billing_period__c}"/>    
                <apex:column value="{!b.cs.Monthly_Forecast__c}"/>
                <apex:column value="{!b.cs.End_of_Billing__c}"/>
                <apex:column value="{!b.cs.Amount__c}"/>
                <apex:column value="{!b.cs.Billing_Status__c}"/>   
                <apex:column >                   
                    <apex:outputLink title="" value="/{!b.cs.Id}/e?retURL=/apex/{!$CurrentPage.Name}" target="_blank" style="font-weight:bold">EDIT</apex:outputLink>
                </apex:column>    
            </apex:pageBlockTable>   
            
        </apex:pageBlock>        
    </apex:form>
</apex:page>

controller:
public class SearchWithWrapperC {
    
    public  Date StartDate {get;set;}
    public  Date EndDate {get;set;}
  
    
    public List<WrapperClass> listBD {get;set;}
   
    
    public void loadData() {
        listBD = new List<WrapperClass>();
        for(Billing_Detail__c  cr : [Select Id,SF_Opportunity_Id__c,Account_Name__c,Billing_Detail__c, Name,Billing_Type__c, Billing_Period__c , Monthly_Forecast__c,End_of_Billing__c, Amount__c, Billing_Status__c   from Billing_Detail__c Where Billing_Status__c='Authorized for Billing'AND Monthly_Forecast__c>=:StartDate AND Monthly_Forecast__c <= :EndDate  Order by Account_Name__c, Monthly_Forecast__c]){
            listBD.add(new WrapperClass (cr, false));
        }
    }
    
        public List<WrapperClass> getBilling() {
            if(listBD == null) {

        listBD = new List<WrapperClass>(); 
        for(Billing_Detail__c  cr : [Select Id,SF_Opportunity_Id__c,Account_Name__c,Billing_Detail__c, Name,Billing_Type__c, Billing_Period__c , Monthly_Forecast__c,End_of_Billing__c, Amount__c, Billing_Status__c   from Billing_Detail__c Where Billing_Status__c='Authorized for Billing'AND Monthly_Forecast__c>=:StartDate AND Monthly_Forecast__c <= :EndDate  Order by Monthly_Forecast__c ]){
            listBD.add(new WrapperClass (cr, false));
        }
        }       
         return listBD;
        }
    
        
   public PageReference processSelected() {
       Integer m = Date.Today().Month();
       List<Billing_Detail__c> selectedBD = new List<Billing_Detail__c>();
       for(WrapperClass bd: getBilling()){
	        Billing_Detail__c billlingDetail ;
           if(bd.check_box== true){
		   
		        billlingDetail = new Billing_Detail__c(Id=bd.cs.Id);
		      billlingDetail.Monthly_Forecast__c = Date.newinstance(  bd.cs.Monthly_Forecast__c.year() , m ,  bd.cs.Monthly_Forecast__c.day() );
			    
               selectedBD.add(billlingDetail);
           } 
       }
       
         
          update selectedBD;
           
       
       
     
       return null;
       
   }
    
    


    
    public class WrapperClass {
        public Billing_Detail__c  cs {get; set;}
        public Boolean check_box {get; set;}
        
        public WrapperClass(Billing_Detail__c  c, Boolean check_box){
            this.cs = c;
            this.check_box = false;
        }
    }
}

I really need help.

Thanks in advance.