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
Rahul Kumar 652Rahul Kumar 652 

How rerender works internally , please let me know i try to debug but i get confused.

When i try to debug the rerender (getter method) ,the debug calls twice once with older data and other with new data , i am confused why the getter method calls twice on debug .
Also i used rendered in two page block tags and the rendered have a condition on same getter method i.e if size of return list from getter method  is greater than 0 than one page block is rendered and is equal to 0 than other page block is rendered, so i also use debug there but it calls  getter method once in any one page block but according to me it should calls the getter method in both of the page block to check the condition .
I attached my vf page code here : 
<apex:page Controller="ShoppingCartController">
        <meta charset="utf-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1" />
        <title>Shopping Ecommerce</title>
        <!-- Import the Design System style sheet -->
        <apex:slds />
        <apex:form >
            <apex:pageBlock title="Purchase Orders History" id="orders_list">
                <apex:selectList value="{!setConPurchase.filterId}" size="1">
                <apex:selectOptions value="{!setConPurchase.listViewOptions}"/>
                <apex:actionSupport event="onchange" reRender="orders_list"/>
                <!-- Orders List -->
                <apex:pageBlockTable value="{!PurchaseOrders}" var="order">
                    <apex:column value="{! order.Id }"/>
                    <apex:column value="{! order.Order_Price__c }"/>
                    <apex:column value="{! order.Status__c }"/>
                <apex:outputText value=" Page: {!setConPurchase.PageNumber} of {! CEILING(setConPurchase.ResultSize / setConPurchase.PageSize) }"/>
                <apex:commandButton rendered="{!setConPurchase.hasPrevious}" value="first" action="{!setConPurchase.first}"/>
                <apex:commandButton rendered="{!setConPurchase.hasPrevious}" value="Previous" action="{!setConPurchase.previous}"/>
                <apex:commandButton rendered="{!setConPurchase.hasNext}" value="next" action="{!}"/>
                <apex:commandButton rendered="{!setConPurchase.hasNext}" value="last" action="{!setConPurchase.last}"/>
                Records per page:
                <apex:selectList value="{! setConPurchase.Pagesize }" size="1">
                    <apex:selectOption itemValue="5" itemLabel="5"/>
                    <apex:selectOption itemValue="20" itemLabel="20"/>
                    <apex:actionSupport event="onchange" reRender="orders_list"/>
            <div align="Center">
                <apex:commandButton value="Add New Purchase" action="{!getProductsPanel}" reRender="products_list"/>
            <apex:outputPanel id="products_list">
                <apex:pageBlock title="Products" rendered="{!render}">
                    <apex:pageMessages id="errors" />
                    <apex:actionFunction name="searchProduct" action="{!search}" reRender="products_table">
                    <apex:inputText value="{!searchText}" html-placeholder="Search Products" onkeyup="searchProduct(this.value)" />
					<apex:commandButton value="Add To Cart" action="{!getProductsPanel}" reRender="products_list" /> 
                    <apex:pageBlock mode="maindetail" id="products_table">
                        <apex:pageBlock rendered="{!If(WrapperProducts.size > 0 ,true,false)}">
                            <apex:pageBlockTable value="{!WrapperProducts}" var="wrapperProduct" >
                                <apex:column title="Select Products">
                                    <apex:inputCheckbox value="{!wrapperProduct.selected}"/>
                                <apex:column value="{! wrapperProduct.product.Name}"/>
                                <apex:column value="{! wrapperProduct.product.ProductCode}"/>
                                <apex:column value="{! wrapperProduct.product.Description}"/>
                                <apex:column value="{! wrapperProduct.product.Quantity__c}"/>
                                <apex:column value="{! wrapperProduct.product.Price_Per_Unit__c}"/>
                        <apex:pageBlock rendered="{!If(WrapperProducts.size==0 ,true,false)}" title="Search Result">            
                            <apex:outputLabel value="No Result Found"></apex:outputLabel>           
                    <apex:outputText value=" Page: {!setConProduct.PageNumber} of {! CEILING(setConProduct.ResultSize / setConProduct.PageSize) }"/>
                    <apex:commandButton rendered="{!setConProduct.hasPrevious}" value="first" action="{!setConProduct.first}"/>
                    <apex:commandButton rendered="{!setConProduct.hasPrevious}" value="Previous" action="{!setConProduct.previous}"/>
                    <apex:commandButton rendered="{!setConProduct.hasNext}" value="next" action="{!}"/>
                    <apex:commandButton rendered="{!setConProduct.hasNext}" value="last" action="{!setConProduct.last}"/>
                    Records per page:
                    <apex:selectList value="{! setConProduct.Pagesize }" size="1">
                        <apex:selectOption itemValue="5" itemLabel="5"/>
                        <apex:selectOption itemValue="20" itemLabel="20"/>
                        <apex:actionSupport event="onchange" reRender="products_list"/>

ANUTEJANUTEJ (Salesforce Developers) 
Hi Rahul,

Rerender used to refresh a particular section of the visual force page. We have to just mention the id of the page section (in the Rerender attribute) that needs to be refreshed.

Hope this helps.

Rahul Kumar 652Rahul Kumar 652
Hi Anutej, 
Thanks for replying but i want to know that when  i try to debug the rerender (getter method) ,the debug calls twice once with older data and other with new data , i am confused why the getter method calls twice on debug .