I am assigning controller properties with some value in its constructor. I am using <apex:actionPoller /> on VF page and it is rerendering some part of visualforce page section. But it not retaining the value of controller properties.

VF Code:

<apex:form >
   <apex:actionPoller action="{!incrementCounter}" reRender="RecTypeCount" interval="20"/>
    <apex:pageBlock title="Select Object" id="pbselobj">
        <apex:pageblocksection columns="1" id="pbsecselobj">
        <apex:commandbutton action="{!fetchdata}" value="show Data" immediate="true"/>    
     <apex:outputPanel id="RecTypeCount"> 
         <apex:outputText value="Watch this counter: {!count}" id="counter"/>
        <apex:pageBlock title="First Name Last Name" >
            <apex:pageBlockTable value="{!mdata}" var="rt1" style="width: 50%;"  >
                <apex:column headerValue="First Name"  value="{!rt1}" style="padding-left: 5px;" >
                <apex:column headerValue="Last Name" value="{!mdata[rt1]}" style="padding-right: 5px; text-align: right;" >

Batch Class Code:

global class TestBatchClassCallingApexClass implements Database.Batchable < sObject >, Database.stateful {
  private List<String> aList = null;
  private Integer currentIndex;
  private Map<String,String> mapName;

  global Database.QueryLocator start(Database.BatchableContext bc){
    String query = 'SELECT Id,Name FROM Account';
    return Database.getQueryLocator(query);

  global void execute(Database.BatchableContext bc, List<sObject> records){
    // process each batch of records

  global void finish(Database.BatchableContext bc){
    // execute any post-processing operations
    mapName = new Map<string, string>();
    mapName.put('James', 'Bond');

    ApexClassCalledByBatch objApx = new ApexClassCalledByBatch();

Apex Controller Code:

public class ApexClassCalledByBatch {

public Map<string, string> mapName {get;set;}
public Map<string, string> varName {get;set;}
public Map<string, string> mnew;
public String test {get;set;}
public Integer count = 0;

public ApexClassCalledByBatch(){
    test ='Hello';
    system.debug('null constructor called');
    mnew = new Map<string, string>();


/*public ApexClassCalledByBatch(Map<string,string> mapName){
    system.debug('mapname status :: ' + mapName);
    mnew = new Map<string, string>();
    test ='Hello1';
    if (mapName == null){
         this.mapName = mapName; 
        mapName = mapName;

    system.debug('mapName' + mapName.keyset());
    mnew = mapName;
    system.debug(' wow ');

public void mapValuedata(Map<string,string> mapName) {

    varName = mapName; 
    mnew = mapName;
    system.debug('varName :: ' + varName);

public Map<string,string> getMdata() { 
    return varName; 

public pagereference showData(){

    Pagereference pf = new PageReference('/apex/BatchVFPage');
    return pf;

public void fetchdata(){
    system.debug('batch class called');
    TestBatchClassCallingApexClass objTBCAC = new TestBatchClassCallingApexClass();
    ID batchprocessid = Database.executeBatch(objTBCAC,200);


public PageReference incrementCounter() {
   // system.debug('mapName value after refresh through action poller' + mapName.keyset());

    varName = getMdata();
    system.debug(mnew +' woow '+varName);
    test ='Hello'+count;
    return null;

public Integer getCount() {
    return count;

  • Can you add relevant code snippets? Aug 20, 2019 at 12:01
  • I have shared the code. I am calling the batch class from visualforce page button. this is assigning values to apex controller properties and i want to render that value to page. I am using actionpoller to keep rerender the section of page where we have to render property value, but it is appearing null. Aug 20, 2019 at 12:22


You must log in to answer this question.

Browse other questions tagged .