+ Start a Discussion
Naveen Ashok Sirivella 3Naveen Ashok Sirivella 3 

How can refresh only second block when i click on submit by using action function

Hi All,

Can you please help me on below things.
Scenario:
---------------------------
I have one VF page which contains 2-page blocks.
On block contains insert operation and the second block contains displaying the list.
When I enter Account name click on submit button only second block needs to be refreshed not the entire page.
VF Page
---------------------
<apex:page controller="Action_Function_scenario_Controller" sidebar="false" lightningStylesheets="true">
<apex:form >

<apex:pageBlock >

<apex:actionFunction action="{!Submit}" name="Submit" reRender="sec"/>

   Account Name :: <apex:inputText value="{!accname}"/>
  <apex:commandButton value="Submit" onclick="doUiSubmit();return false;" id="checkBtn"/>
</apex:pageBlock>


<apex:pageBlock title="Displying List of records" id="sec">
  <apex:pageBlockSection title="Account list" collapsible="false">
    <apex:pageBlockTable value="{!acclist}" var="a">
        <apex:column value="{!a.name}"/>
        <apex:column value="{!a.rating}"/>
        <apex:column value="{!a.industry}"/>
        <apex:column value="{!a.description}"/>
    </apex:pageBlockTable>
  </apex:pageBlockSection>
</apex:pageBlock>


</apex:form>
</apex:page>

Controller
------------------------
public with sharing class Action_Function_scenario_Controller {

    public string accname{get;set;}
    Public list<Account> acclist{get;set;}
    
    public Action_Function_scenario_Controller()
    {
       acclist = new List<Account>();
       
       acclist = [select name,rating,industry,description from account order by createdDate DESC limit 10];
    }
    
    public PageReference Submit()
    {
       Account ac = new Account();
       ac.Name = accname;
       
       insert ac;
       
       return null;
    }
}
AlibabaAlibaba
Try Apex:OutputPanel