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
SandromedaSandromeda 

Rerender a section with new data upon page refresh

My VF page is divided into two sections: 

Top section has a text box and a command button (Submit) that takes in an employee id and populates a page block table with devices issued to the employee. 

Bottom section has a page block table where you input new serial numbers and update the employee by issuing new devices to them upon clicking the save button. 

When I click the save button in the botton section, the code executes perfectly in the back end. But the page refreshes after save. However, the table in the top section does not rerender to show the new devices. I have to click on the Submit button again for it to repopulate with the new data. 

Is there any way I can refresh the first table as soon as the page is reloaded after Save? 
SandromedaSandromeda
I just realized I can't edit my question. 

I've tried combinations of rerender = 'xxx' too, of course. Doesn't work.
Vidhyasagaran MuralidharanVidhyasagaran Muralidharan
<apex:actionSupport action="{!save}" rerender="topBlock"/> this will work i guess or
<apex:actionSupport action="{!save}" rerender="toppageBlocktable id"/> this will work i guess
if the table doesnot populate the new values.in the rerender attribute give pageblock table "ID"
AshwaniAshwani
Sandromeda,

Following things you may try:

- Use a single <apex:form> on visualforce page

- Try to rerender complete pageblock on submit button

- Make sure You do not calling action function in page between pageblock.

Also If you can post code here then It may help in understanding actual issue.
Virendra ChouhanVirendra Chouhan
Hi Sandromeda,

Can you post code snipt?
SandromedaSandromeda
I have three objects: employee, inventory, and issued  that acts as a junction object between the two.

VISUALFORCE 

<apex:tab label="New Items Issuance" id="newItem" >
          <apex:pageBlock >
                  <apex:pageBlockSection >
                      <apex:form >
                          Employee Id : <apex:inputText maxlength="100" value="{!empNoEmail}"/>
                          <apex:commandButton value="Submit" action="{!empDetails}"/>
                      </apex:form>
                  </apex:pageBlockSection>
                  <apex:pageBlockSection columns="1" title="Employee Details" rendered="{!AND(NOT(ISNULL(empLst)),empLst.size>0)}">
                      <apex:pageBlockTable value="{!empLst}" var="emp">
                          ----- retrieve employee details ----
                      </apex:pageBlockTable>
                  </apex:pageBlockSection>
                  <apex:pageBlockSection rendered="{!AND(OR(ISNULL(empLst),empLst.size=0),isRender)}">
                    <i>No records to display.</i>
                  </apex:pageBlockSection>
          </apex:pageBlock>
          <apex:PageBlock rendered="{!OR((AND(NOT(ISNULL(issuedObjLst)),issuedObjLst.size>0)), issuanceWrapLst.size>0)}">
              <apex:PageBlockSection columns="1" title="Assigend Products/Assets" >
                  <apex:PageBlockTable value="{!issuedObjLst}" var="itm">
                      <apex:column headerValue="Serial Number">
                            <apex:outputLabel value="{!itm.obIssud.Inventory_Name__r.Serial_Number__c }"/>
                        </apex:column>
                        <apex:column headerValue="Category">
                            <apex:outputLabel value="{!itm.obIssud.Inventory_Name__r.Product__r.Category__r.Name}"/>
                        </apex:column>
                       ------ 3 more columns here. This is the table that is to be rerendered ------ 
                  </apex:PageBlockTable>
              </apex:PageBlockSection>
          </apex:PageBlock>
          <apex:pageBlock id="issSecBlk" rendered="{!AND(NOT(ISNULL(empLst)),empLst.size>0)}">
              <apex:pageBlockSection columns="1" id="issuSec">
                  <apex:form >
                     Date:  <apex:inputField value="{!objIssued.Issued_Date__c}" required="true"/>
                 </apex:form>
                 <apex:form id="issFrm">
                     <apex:pageblockTable value="{!issuanceWrapLst}" var="wrap" id="wtable" >
                         <apex:column headerValue="Serial Number" id="col1">
                               <apex:inputField value="{!wrap.iss.Serial_Number__c}" onchange="getFetch(this)" id="sInput" onkeypress="return noenter(event)">
                               </apex:inputField>
                         </apex:column>
                         <apex:column headerValue="Category" id="col2">
                             <apex:inputText value="{!wrap.iss.Product__r.Category__r.Name}" id="cat" disabled="true"/>
                         </apex:column>
                         ------5 more columns here ----- 
                     </apex:pageblockTable>
                  </apex:form>
              </apex:pageBlockSection>
              <apex:pageBlockSection id="itmsSave" columns="1">
                  <apex:form id="cmdButton">
                      <apex:commandButton value="Save Items" onclick="serialNo()">
                          <apex:actionFunction action="{!saveItems}"   name="saveItems" reRender="issFrm">
                            <apex:param assignTo="{!rowIdValue}" name="rowIdValue" value=""/>
                            <apex:param assignTo="{!isdDate}" name="IsdDate" value=""/>
                          </apex:actionFunction>
                      </apex:commandButton>
                  </apex:form>
              </apex:pageBlockSection>
          </apex:pageBlock>
      </apex:tab>

JAVASCRIPT
SerialNo() function concatenates IDs of the new issues. 


CONTROLLER (simplified code)

public pagereference empDetails()      // simplified code
    {
        empLst.clear();
        isItemsRndr = false;
       
            empLst = [SELECT Id, Name, Department__c,Email__c FROM Employees__c WHERE Name =:empNoEmail];

            for(Employees__c  objEmp : empLst)
            {
                empIds.add(objEmp .Id);
            }
            issuedObjLst.clear();
            for(Issued__c issuedObj: [Select Id,Inventory_Name__r.Serial_Number__c,Inventory_Name__r.Product__r.Category__r.Name,Reason_for_return__c from Issued__c where Employee_Id__c IN:empIds ])

                issuedObjLst.add(new issuedObjWrapper(issuedObj));
      
        if(empLst.isEmpty()&& empNoEmail != null && empNoEmail != '')
        {
            isRender = true;
        }
      return null;
    }

public pagereference saveItems(){
         String[] serilNoList=null;              
         serilNoList=rowIdValue.split(',');     

        Employees__c empObj = [Select Id, Name, Employee_Name__c from Employees__c WHERE Name =:empNoEmail or Email__c =:empNoEmail];
       
        invLst = [Select Id from Inventory_del__c where Serial_Number__c IN:serilNoList];
       
        for(Inventory_del__c objInven: invLst)
        {
            Inventory_del__c obInv = new Inventory_del__c();
            Issued__c obIssed = new Issued__c();
           
            obInv.Id = objInven.Id;
            obInv.Status__c = 'Issued';
            invIssuedLst.add(obInv);
            obIssed.Employee_Id__c = empObj.Id;
            obIssed.Inventory_Name__c = objInven.Id;
            obIssed.Issued_Date__c = isdDate;
            issuedItmLst.add(obIssed);
        }
       
        update invIssuedLst;
        insert issuedItmLst;
        if(issuedItmLst.size() >0 )
        {
            isItemsRndr = true;
             isRender = true;
        }
        empDetails();    // calling the method again to rerender the table 
        return null;
     }


Abhishek MadhuAbhishek Madhu
Does anyone have ideas about this yet? I think I got a similar issue.